From 45f7770ca2bb19e91d1c9a11e4a223b6ea91f9a9 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Sun, 5 Feb 2023 18:16:58 -0500 Subject: [PATCH] [decomp] finish up `nav-graph`, `traffic-engine`, `traffic-manager`, `height-map` (#2191) Some of these were almost done, just needed a few more types. --- decompiler/config/jak2/all-types.gc | 608 +-- .../jak2/anonymous_function_types.jsonc | 5 +- decompiler/config/jak2/hacks.jsonc | 2 +- decompiler/config/jak2/label_types.jsonc | 8 +- decompiler/config/jak2/stack_structures.jsonc | 26 +- decompiler/config/jak2/type_casts.jsonc | 122 +- goal_src/jak2/engine/ai/traffic-h.gc | 67 +- goal_src/jak2/engine/anim/joint-exploder.gc | 2 +- .../engine/common_objs/rigid-body-plat.gc | 12 +- .../jak2/engine/debug/nav/mysql-nav-graph.gc | 19 +- .../jak2/engine/debug/nav/nav-graph-editor.gc | 8 + goal_src/jak2/engine/game/pilot-h.gc | 2 +- goal_src/jak2/engine/level/bsp-h.gc | 4 +- goal_src/jak2/engine/physics/rigid-body-h.gc | 8 +- goal_src/jak2/engine/physics/rigid-body.gc | 16 +- goal_src/jak2/engine/sound/speech-h.gc | 3 + goal_src/jak2/engine/target/target-h.gc | 14 +- goal_src/jak2/engine/target/target-handler.gc | 23 +- goal_src/jak2/game.gp | 3 +- goal_src/jak2/levels/city/common/bike.gc | 1541 +++++++ goal_src/jak2/levels/city/common/car.gc | 1659 +++++++ .../jak2/levels/city/common/citizen-chick.gc | 10 + .../jak2/levels/city/common/citizen-enemy.gc | 14 + .../jak2/levels/city/common/citizen-norm.gc | 10 + .../jak2/levels/city/common/ctyport-obs.gc | 14 +- .../jak2/levels/city/common/ctywide-obs-h.gc | 2 + .../jak2/levels/city/common/ctywide-speech.gc | 4 + goal_src/jak2/levels/city/common/guard.gc | 116 + .../jak2/levels/city/common/height-map-h.gc | 14 +- .../jak2/levels/city/common/height-map.gc | 244 + .../levels/city/common/metalhead-flitter.gc | 28 + .../levels/city/common/metalhead-grunt.gc | 34 + .../levels/city/common/metalhead-predator.gc | 36 + .../jak2/levels/city/common/nav-graph-h.gc | 127 +- goal_src/jak2/levels/city/common/nav-graph.gc | 1359 ++++++ .../jak2/levels/city/common/pilot-states.gc | 1076 +++++ .../jak2/levels/city/common/target-pilot.gc | 475 ++ goal_src/jak2/levels/city/common/test-bike.gc | 469 ++ goal_src/jak2/levels/city/common/test-car.gc | 281 ++ .../levels/city/common/traffic-engine-h.gc | 242 +- .../jak2/levels/city/common/traffic-engine.gc | 3771 ++++++++++++++- .../levels/city/common/traffic-manager.gc | 860 ++++ goal_src/jak2/levels/city/common/transport.gc | 6 +- .../levels/city/common/vehicle-effects.gc | 13 +- .../jak2/levels/city/common/vehicle-guard.gc | 14 +- goal_src/jak2/levels/city/common/vehicle-h.gc | 22 +- .../levels/city/common/vehicle-physics.gc | 2 +- .../jak2/levels/city/common/vehicle-rider.gc | 8 +- .../jak2/levels/city/common/vehicle-states.gc | 2 +- .../jak2/levels/city/common/vehicle-util.gc | 41 +- goal_src/jak2/levels/city/common/vehicle.gc | 32 +- .../misc/collection_task/collection-task.gc | 2 +- .../city/misc/delivery/delivery-task.gc | 7 +- .../jak2/levels/city/port/mines/portrun.gc | 2 +- .../city/side_missions/ctywide-bbush.gc | 5 +- goal_src/jak2/levels/dig/dig-obs.gc | 6 +- goal_src/jak2/levels/dig/dig1-obs.gc | 10 +- goal_src/jak2/levels/dig/dig3-obs.gc | 16 +- goal_src/jak2/levels/ruins/ruins-obs.gc | 6 +- goal_src/jak2/levels/underport/under-obs.gc | 6 +- goalc/compiler/compilation/Type.cpp | 9 +- .../reference/jak2/engine/ai/traffic-h_REF.gc | 32 +- .../jak2/engine/anim/joint-exploder_REF.gc | 2 +- .../engine/common_objs/rigid-body-plat_REF.gc | 12 +- .../engine/debug/nav/mysql-nav-graph_REF.gc | 21 +- .../reference/jak2/engine/game/pilot-h_REF.gc | 2 +- .../reference/jak2/engine/level/bsp-h_REF.gc | 2 +- .../reference/jak2/engine/level/level_REF.gc | 4 +- .../jak2/engine/physics/rigid-body-h_REF.gc | 8 +- .../jak2/engine/physics/rigid-body_REF.gc | 16 +- .../jak2/engine/target/target-h_REF.gc | 12 +- .../jak2/engine/target/target-handler_REF.gc | 23 +- .../jak2/levels/city/common/bike_REF.gc | 1689 +++++++ .../levels/city/common/ctyport-obs_REF.gc | 14 +- .../levels/city/common/ctywide-tasks_REF.gc | 6 +- .../levels/city/common/height-map-h_REF.gc | 14 +- .../jak2/levels/city/common/height-map_REF.gc | 264 ++ .../levels/city/common/nav-graph-h_REF.gc | 106 +- .../jak2/levels/city/common/nav-graph_REF.gc | 1475 ++++++ .../levels/city/common/pilot-states_REF.gc | 1072 +++++ .../levels/city/common/target-pilot_REF.gc | 487 ++ .../jak2/levels/city/common/test-bike_REF.gc | 508 +++ .../jak2/levels/city/common/test-car_REF.gc | 304 ++ .../city/common/traffic-engine-h_REF.gc | 219 +- .../levels/city/common/traffic-engine_REF.gc | 4053 +++++++++++++++++ .../levels/city/common/traffic-manager_REF.gc | 166 +- .../jak2/levels/city/common/transport_REF.gc | 6 +- .../levels/city/common/vehicle-effects_REF.gc | 8 +- .../levels/city/common/vehicle-guard_REF.gc | 14 +- .../jak2/levels/city/common/vehicle-h_REF.gc | 22 +- .../levels/city/common/vehicle-physics_REF.gc | 2 +- .../levels/city/common/vehicle-rider_REF.gc | 8 +- .../levels/city/common/vehicle-states_REF.gc | 2 +- .../levels/city/common/vehicle-util_REF.gc | 42 +- .../jak2/levels/city/common/vehicle_REF.gc | 32 +- .../collection_task/collection-task_REF.gc | 2 +- .../city/misc/delivery/delivery-task_REF.gc | 11 +- .../levels/city/port/mines/portrun_REF.gc | 2 +- .../city/side_missions/ctywide-bbush_REF.gc | 9 +- .../common/enemy/bombots/bombbot_REF.gc | 2 +- .../reference/jak2/levels/dig/dig-obs_REF.gc | 6 +- .../reference/jak2/levels/dig/dig1-obs_REF.gc | 10 +- .../reference/jak2/levels/dig/dig3-obs_REF.gc | 16 +- .../jak2/levels/ruins/ruins-obs_REF.gc | 6 +- .../jak2/levels/underport/under-obs_REF.gc | 6 +- test/offline/config/jak2/config.jsonc | 8 +- 106 files changed, 23227 insertions(+), 1045 deletions(-) create mode 100644 test/decompiler/reference/jak2/levels/city/common/bike_REF.gc create mode 100644 test/decompiler/reference/jak2/levels/city/common/height-map_REF.gc create mode 100644 test/decompiler/reference/jak2/levels/city/common/nav-graph_REF.gc create mode 100644 test/decompiler/reference/jak2/levels/city/common/pilot-states_REF.gc create mode 100644 test/decompiler/reference/jak2/levels/city/common/target-pilot_REF.gc create mode 100644 test/decompiler/reference/jak2/levels/city/common/test-bike_REF.gc create mode 100644 test/decompiler/reference/jak2/levels/city/common/test-car_REF.gc create mode 100644 test/decompiler/reference/jak2/levels/city/common/traffic-engine_REF.gc diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 292dc379c4..31262d4d72 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -9003,17 +9003,41 @@ :size-assert #x29 :flag-assert #xd00000029 (:methods - (traffic-suppression-params-method-9 (_type_) symbol 9) - (traffic-suppression-params-method-10 (_type_) symbol 10) + (try-creating-new-suppression-box "Try getting new suppression box, return if it succeeded. ID is stored in the params." (_type_) symbol 9) + (create-or-update-suppression-box "If the params are already associated with a box, update. Otherwise, attempt to create a new one." (_type_) symbol 10) (has-valid-id? (_type_) none 11) - (traffic-suppression-params-method-12 (_type_) none 12) + (kill-suppression-box "Kill a suppression box, and inform the traffic manager by setting duration to 0." (_type_) none 12) ) ) +;; +++traffic-h:traffic-type +(defenum traffic-type + :type uint8 + (citizen-norm-1 0) + (citizen-chick 1) + (citizen-fat 2) + (citizen-norm-2 3) + (crimson-guard-0 4) + (crimson-guard-1 6) + (crimson-guard-2 7) + (metalhead-grunt 8) + (metalhead-flitter 9) + (metalhead-predator 10) + (bikea 11) + (bikeb 12) + (bikec 13) + (cara 14) + (carb 15) + (carc 16) + (guard-bike 18) + (hellcat 19) + ) +;; ---traffic-h:traffic-type + (declare-type nav-mesh basic) (declare-type nav-branch structure) (deftype traffic-object-spawn-params (structure) - ((object-type uint8 :offset-assert 0) + ((object-type traffic-type :offset-assert 0) (behavior uint64 :offset-assert 8) (id uint32 :offset-assert 16) (nav-mesh nav-mesh :offset-assert 20) @@ -13308,6 +13332,9 @@ (speech-type-1 1) (speech-type-2 2) (speech-type-3 3) + (speech-type-4 4) + (speech-type-5 5) + ) ;; ---speech-h:speech-type @@ -18389,8 +18416,8 @@ target-mech-stance (target-mech-start handle float symbol) target-mech-walk - target-pilot-edge-grab - (target-pilot-start handle) + (target-pilot-edge-grab pilot-edge-grab-info) + (target-pilot-start handle symbol symbol) (target-play-anim string handle) (target-pole-cycle handle) (target-pole-flip-forward float float float) @@ -18427,6 +18454,14 @@ (target-warp-in vector vector target) ;; (define-extern target-warp-in state) ;; (state vector vector target) (target-warp-out vector vector target) ;; (define-extern target-warp-out state) ;; (state vector vector target) target-yellow-jump-blast ;; called in (code target-flop), but not defined, causes crash on PCSX2 + target-pilot-stance + target-pilot-impact + target-pilot-get-on + target-pilot-get-off + target-pilot-grab + (target-pilot-clone-anim handle) + (target-pilot-hit symbol attack-info) + (target-pilot-death symbol) ) ) @@ -18619,6 +18654,7 @@ (declare-type entity-race-mesh entity) (declare-type entity-nav-mesh entity) (declare-type actor-group basic) +(declare-type city-level-info structure) (defenum texture-page-flag :type uint16 @@ -18673,8 +18709,7 @@ ;; 200 is some array ;; 204 is maybe that array's length (wind-array-length int32 :offset 204) - ;; 208 is a structure of some sort - (method 97 vehicle) - (bsp-header-jkh1b23 clock :offset 208) + (city-level-info city-level-info :offset 208) (vis-spheres vector-array :offset 216) (region-tree drawable-tree-region-prim :offset 252) @@ -18936,6 +18971,13 @@ ) ) +(deftype collide-query-with-5vec (structure) + "A custom type" + ((cquery collide-query :inline) + (vec vector 5 :inline) + ) + ) + (deftype do-push-aways-work (structure) "Added" ((cquery collide-query :inline) @@ -28251,7 +28293,7 @@ (seat-index int8 :offset-assert 41) (backup-nav-radius float :offset-assert 44) (cam-side-shift float :offset-assert 48) - (enable-cam-side-shift basic :offset-assert 52) + (enable-cam-side-shift symbol :offset-assert 52) (gun? symbol :offset-assert 56) (controls vehicle-controls :inline :offset-assert 60) (accel-array vector 8 :inline :offset-assert 80) @@ -31783,7 +31825,7 @@ (width float :offset-assert 60) (minimap_edge_flag nav-minimap-edge-flag :offset-assert 64) ) - :pack-me + :allow-misaligned :method-count-assert 10 :size-assert #x44 :flag-assert #xa00000044 @@ -31826,7 +31868,7 @@ ) (deftype mysql-nav-graph-level-info (structure) - ((level string :offset-assert 0) + ((level symbol :offset-assert 0) ;; ?? (level-id uint32 :offset-assert 4) (node-count int32 :offset-assert 8) (branch-count int32 :offset-assert 12) @@ -33316,12 +33358,12 @@ (active () _type_ :state 28) (rigid-body-object-method-29 (_type_ float) none 29) (rigid-body-object-method-30 (_type_) none 30) - (rigid-body-object-method-31 (_type_ rigid-body-object-constants) none 31) - (rigid-body-object-method-32 (_type_) none 32) - (rigid-body-object-method-33 (_type_) none 33) + (alloc-and-init-rigid-body-control (_type_ rigid-body-object-constants) none 31) + (allocate-and-init-cshape (_type_) none 32) + (init-skel-and-rigid-body (_type_) none 33) (rigid-body-object-method-34 (_type_) none 34) (rigid-body-object-method-35 (_type_) none 35) - (rigid-body-object-method-36 (_type_) none 36) + (do-engine-sounds (_type_) none 36) (rigid-body-object-method-37 (_type_) none 37) (rigid-body-object-method-38 (_type_) none 38) (rigid-body-object-method-39 (_type_) none 39) @@ -34039,7 +34081,7 @@ (deftype joint-exploder-static-params (basic) ((joints (array joint-exploder-static-joint-params) :offset-assert 4) ;; guessed by decompiler (collide-spec uint32 :offset-assert 8) - (art-level basic :offset-assert 12) + (art-level symbol :offset-assert 12) ) :method-count-assert 9 :size-assert #x10 @@ -48472,16 +48514,37 @@ ;; nav-graph-h ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defenum nav-branch-clock-type + :type uint8 + (no-clock 0) + (clock2 1) + (clock3 2) + (clock4 3) + ) + +(defenum nav-branch-clock-mask + :type uint8 + :bitfield #t + (phase-1 0) + (phase-1a 1) + (phase-2 2) + (phase-2a 3) + (phase-3 4) + (phase-3a 5) + (phase-4 6) + (phase-4a 7) + ) + (declare-type nav-node structure) (deftype nav-branch (structure) - ((node int32 2 :offset-assert 0) + ((node nav-node 2 :offset-assert 0) (src-node nav-node :offset 0) (dest-node nav-node :offset 4) (temp-dest-node-id int32 :offset 4) (speed-limit uint8 :offset-assert 8) (density uint8 :offset-assert 9) - (clock-type uint8 :offset-assert 10) - (clock-mask uint8 :offset-assert 11) + (clock-type nav-branch-clock-type :offset-assert 10) + (clock-mask nav-branch-clock-mask :offset-assert 11) (max-user-count uint8 :offset-assert 12) (user-count uint8 :offset-assert 13) (width uint8 :offset-assert 14) @@ -48491,8 +48554,8 @@ :size-assert #x10 :flag-assert #x1500000010 (:methods - (nav-branch-method-9 (_type_) none 9) - (nav-branch-method-10 (_type_ object int) none 10) + (set-default-density-speed-and-width (_type_) none 9) + (debug-print (_type_ object int) none 10) (get-density "TODO @returns `density * 0.0078125` - is this some kind of trick?" @@ -48510,11 +48573,11 @@ "@returns if `dest-node`'s `id` is equal to `#FFFF` @see [[nav-node]]" (_type_) symbol 15) - (nav-branch-method-16 (_type_ float) none 16) - (nav-branch-method-17 (_type_ float) none 17) - (nav-branch-method-18 (_type_ float) none 18) - (nav-branch-method-19 (_type_ nav-node) none 19) - (nav-branch-method-20 (_type_ nav-node) none 20) + (set-density (_type_ float) none 16) + (set-speed-limit (_type_ float) none 17) + (set-width (_type_ float) none 18) + (set-src-node (_type_ nav-node) none 19) + (set-dst-node (_type_ nav-node) none 20) ) ) @@ -48550,15 +48613,15 @@ :size-assert #x20 :flag-assert #x1600000020 (:methods - (nav-node-method-9 (_type_) none 9) - (nav-node-method-10 (_type_ symbol string) none 10) - (nav-node-method-11 (_type_ int) none 11) - (nav-node-method-12 (_type_ vector nav-node) none 12) - (nav-node-method-13 (_type_ vector) none 13) - (nav-node-method-14 (_type_ vector) none 14) - (nav-node-method-15 (_type_ uint) none 15) - (nav-node-method-16 (_type_ float) none 16) - (nav-node-method-17 (_type_ float) none 17) + (debug-draw (_type_) none 9) + (debug-print (_type_ symbol string) none 10) + (remove-branch-by-idx (_type_ int) none 11) + (init-from-pt-and-heading (_type_ vector vector) none 12) + (set-pos-xyz (_type_ vector) none 13) + (set-angle-from-heading (_type_ vector) none 14) + (set-id-and-link-branches-back (_type_ uint) none 15) + (set-radius (_type_ float) none 16) + (set-angle (_type_ float) none 17) (get-position "@param! ret The [[vector]] that is modified to hold the result @returns the `position` [[vector]] with a `w` component of `1.0`" @@ -48608,35 +48671,35 @@ :flag-assert #x2d0000003c (:methods (new (symbol type int int int uint) _type_ 0) - (nav-graph-method-9 (_type_) none 9) + (debug-draw-nodes (_type_) none 9) (nav-graph-method-10 (_type_ vector int) none 10) (nav-graph-method-11 (_type_) none 11) (nav-graph-method-12 (_type_) none 12) (nav-graph-method-13 (_type_ int int) none 13) (nav-graph-method-14 (_type_ int int) none 14) - (nav-graph-method-15 (_type_) none 15) - (nav-graph-method-16 (_type_ int) nav-node 16) - (nav-graph-method-17 (_type_ nav-node) none 17) - (nav-graph-method-18 (_type_ nav-node int) none 18) + (debug-reset (_type_) none 15) + (debug-add-node (_type_ int) nav-node 16) + (debug-link-node-to-graph (_type_ nav-node) none 17) + (debug-reset-branch-array "kinda dangerous" (_type_ nav-node int) none 18) (nav-graph-method-19 (_type_ int int int int int int) none 19) (nav-graph-method-20 (_type_ int int) none 20) - (nav-graph-method-21 (_type_) none 21) - (nav-graph-method-22 (_type_ int int) none 22) - (nav-graph-method-23 (_type_ int int) none 23) - (nav-graph-method-24 (_type_ int int) none 24) - (nav-graph-method-25 (_type_ symbol symbol) none 25) - (nav-graph-method-26 (_type_ symbol symbol) none 26) - (nav-graph-method-27 (_type_ nav-node-flag-byte nav-node-flag-byte symbol) none 27) - (nav-graph-method-28 (_type_) none 28) - (nav-graph-method-29 (_type_ symbol) none 29) - (nav-graph-method-30 (_type_ uint) none 30) - (nav-graph-method-31 (_type_ float) none 31) - (nav-graph-method-32 (_type_ float) none 32) - (nav-graph-method-33 (_type_ float) none 33) - (nav-graph-method-34 (_type_ float) none 34) - (nav-graph-method-35 (_type_ int) none 35) - (nav-graph-method-36 (_type_ int) none 36) - (nav-graph-method-37 (_type_ vector) none 37) + (move-selected-to-height-map-height (_type_) none 21) + (select-nodes-in-range (_type_ int int) none 22) + (deselect-nodes-in-range (_type_ int int) none 23) + (toggle-select-nodes-in-range (_type_ int int) none 24) + (select-nodes-in-level (_type_ symbol symbol) none 25) + (select-nodes-by-nav-mesh-id (_type_ int symbol) none 26) + (select-nodes-by-flags (_type_ nav-node-flag-byte nav-node-flag-byte symbol) none 27) + (print-selected-nodes (_type_) none 28) + (assign-selected-nodes-to-level (_type_ symbol) none 29) + (assign-selected-nodes-to-nav-mesh (_type_ uint) none 30) + (set-radius-of-selected-nodes (_type_ float) none 31) + (set-speed-limit-of-selected (_type_ float) none 32) + (set-density-of-selected (_type_ float) none 33) + (set-width-of-selected (_type_ float) none 34) + (or-flags-of-selected-nodes (_type_ nav-node-flag-byte) none 35) + (and-flags-of-selected-nodes (_type_ nav-node-flag-byte) none 36) + (offset-pos-of-selected (_type_ vector) none 37) (nav-graph-method-38 (_type_) none 38) (nav-graph-method-39 (_type_) none 39) (nav-graph-method-40 (_type_ int) int 40) @@ -48645,9 +48708,10 @@ @param idx The position in the `node-array` to return @returns the [[nav-node]] if it can be found, otherwise return [[#f]]" (_type_ int) nav-node 41) - (nav-graph-method-42 (_type_) none 42) - (nav-graph-method-43 (_type_ nav-graph-link string) none 43) - (from-editor (_type_ nav-node symbol) none 44) + (patch-nodes "Patch nodes. Node pointers are stored as indices into arrays to be allocated on the level heap + and patched at runtime after loading." (_type_) none 42) + (copy-to-mysql-graph (_type_ mysql-nav-graph string) none 43) + (from-editor (_type_ mysql-nav-graph symbol) none 44) ) ) @@ -48700,8 +48764,8 @@ :size-assert #x20 :flag-assert #xb00000020 (:methods - (vis-cell-method-9 (_type_) none 9) - (vis-cell-method-10 (_type_) none 10) + (reset-segment-counts (_type_) none 9) + (debug-draw (_type_) none 10) ) ) @@ -48751,11 +48815,11 @@ :size-assert #x40 :flag-assert #xe00000040 (:methods - (grid-info-method-9 (_type_ (pointer bounding-box) int int) none 9) - (grid-info-method-10 (_type_ vis-grid-pos vector) none 10) - (grid-info-method-11 (_type_ vis-grid-box vector) none 11) - (grid-info-method-12 (_type_ rgba) none 12) - (grid-info-method-13 (_type_ vis-grid-pos rgba) none 13) ;; vis-grid-pos is a total guess + (setup-grid-from-bounding-box "Set up a grid which fills the given bounding box" (_type_ (pointer bounding-box) int int) none 9) + (lookup-cell-for-point "Get the grid cell containing the point (or closest, if outside the grid)" (_type_ vis-grid-pos vector) none 10) + (lookup-box-for-sphere "Get the box of cells containing the given sphere" (_type_ vis-grid-box vector) none 11) + (debug-draw-grid (_type_ rgba) none 12) + (debug-draw-cell (_type_ vis-grid-pos rgba) none 13) ;; vis-grid-pos is a total guess ) ) @@ -48766,7 +48830,7 @@ (cell-array (inline-array vis-cell) :offset-assert 64) (segment-count int16 :offset-assert 68) (cell-count uint16 :offset-assert 70) - (segment-array uint32 :offset-assert 72) + (segment-array (inline-array nav-segment) :offset-assert 72) ;; elt size is 0x30 (nav-graph nav-graph :offset-assert 76) (camera-ceiling meters :offset-assert 80) (pad-array int8 56 :offset-assert 84) @@ -48776,14 +48840,14 @@ :flag-assert #x130000008c (:methods (city-level-info-method-9 (_type_) symbol 9) - (city-level-info-method-10 (_type_ vis-ray vector vector) none 10) + (init-vis-ray (_type_ vis-ray vector vector) none 10) (city-level-info-method-11 (_type_ vis-ray) none 11) (city-level-info-method-12 (_type_ vector nav-branch vector) vector 12) - (city-level-info-method-13 (_type_ vector) none 13) - (city-level-info-method-14 (_type_ vis-grid-box) vis-cell 14) - (city-level-info-method-15 (_type_ int int) symbol 15) - (city-level-info-method-16 (_type_ vector int traffic-find-segment-struct (function traffic-find-segment-struct object none)) none 16) - (city-level-info-method-17 (_type_ traffic-engine) none 17) + (lookup-cell-by-position (_type_ vector) vis-cell 13) + (get-first-cell-in-box (_type_ vis-grid-box) vis-cell 14) + (sphere-in-grid? (_type_ int int) symbol 15) + (callback-on-nav-segments-in-sphere (_type_ vector int traffic-find-segment-struct (function traffic-find-segment-struct nav-segment none)) none 16) + (update-suppressions-from-traffic-engine (_type_ traffic-engine) none 17) (city-level-info-method-18 (_type_) none 18) ) ) @@ -48800,20 +48864,34 @@ :size-assert #x820 :flag-assert #xf00000820 (:methods - (traffic-level-data-method-9 (_type_) none 9) - (traffic-level-data-method-10 (_type_ vis-cell) none 10) - (traffic-level-data-method-11 (_type_ int) none 11) - (traffic-level-data-method-12 (_type_ vis-cell) none 12) - (traffic-level-data-method-13 (_type_) vis-cell 13) - (traffic-level-data-method-14 (_type_) none 14) + (reset (_type_) none 9) + (add-active-cell (_type_ vis-cell) none 10) + (remove-active-cell (_type_ int) none 11) + (add-newly-active-cell (_type_ vis-cell) none 12) + (per-frame-cell-update (_type_) none 13) + (debug-draw (_type_) none 14) ) ) +;; maybe the same as traffic-suppression-flags +(defenum traffic-suppression-box-flags + :type uint8 + :bitfield #t + (in-use 0) + (tfsb1 1) + (tfsb2 2) + (tfsb3 3) + (tfsb4 4) + (tfsb5 5) + (tfsb6 6) + (tfsb7 7) + ) + (deftype traffic-suppression-box (structure) ((data uint8 32 :offset-assert 0 :score -999) (bbox bounding-box :inline :offset 0) - (flags uint8 :offset 12) - (duration uint32 :offset 28) + (flags traffic-suppression-box-flags :offset 12) + (duration uint32 :offset 28 :score 1) ) :method-count-assert 9 :size-assert #x20 @@ -48821,7 +48899,7 @@ ) (deftype traffic-guard-type-info (structure) - ((object-type uint8 :offset-assert 0) + ((object-type traffic-type :offset-assert 0) (max-target-count int8 :offset-assert 1) (min-target-count int8 :offset-assert 2) (target-count int8 :offset-assert 3) @@ -48912,7 +48990,7 @@ (duration uint32 :offset-assert 16) (start-time time-frame :offset-assert 24) (notify-time time-frame :offset-assert 32) - (alarm-sound-id uint32 :offset-assert 40) + (alarm-sound-id sound-id :offset-assert 40) (target-status-array traffic-target-status 3 :inline :offset-assert 48) (settings traffic-alert-state-settings :inline :offset-assert 288) (guard-type-info-array traffic-guard-type-info 6 :inline :offset-assert 384) @@ -48922,7 +49000,7 @@ :size-assert #x3d8 :flag-assert #xa000003d8 (:methods - (traffic-alert-state-method-9 (_type_) none 9) + (reset (_type_) none 9) ) ) @@ -48945,8 +49023,21 @@ :flag-assert #x900000014 ) +(defenum traffic-suppression-flags + :type uint8 + :bitfield #t + (tfs0 0) + (needs-update 1) + (tfs2 2) + (tfs3 3) + (tfs4 4) + (tfs5 5) + (tfs6 6) + (tfs7 7) + ) + (deftype traffic-suppressor (structure) - ((flags uint8 :offset-assert 0) + ((flags traffic-suppression-flags :offset-assert 0) (bbox bounding-box :inline :offset-assert 16) (array traffic-suppression-box 16 :inline :offset-assert 48) ) @@ -48954,11 +49045,12 @@ :size-assert #x230 :flag-assert #xe00000230 (:methods - (traffic-suppressor-method-9 (_type_) none 9) - (traffic-suppressor-method-10 (_type_ traffic-suppression-params) none 10) - (traffic-suppressor-method-11 (_type_ int) none 11) - (traffic-suppressor-method-12 (_type_ traffic-suppression-params) none 12) - (traffic-suppressor-method-13 (_type_) none 13) + (reset-boxes "Clears some flags, mark all boxes as disabled." (_type_) none 9) ;; clear flags 0, 1 on self and boxes. + (add-new-supression-box "Create a suppression box for these params. + The param object is updated with the ID of the box and can be later used with update-box-from-params." (_type_ traffic-suppression-params) none 10) + (remove-box-by-id "Remove a box that was previously added, by its ID." (_type_ int) none 11) + (update-box-from-params "Update a box that was previously added" (_type_ traffic-suppression-params) none 12) + (debug-draw (_type_) none 13) ) ) @@ -48971,7 +49063,7 @@ (active-object-count uint8 :offset-assert 13) (inactive-object-count int8 :offset-assert 14) (active-object-list handle 126 :offset-assert 16) - (active-object-type-list uint8 126 :offset-assert 1024) + (active-object-type-list traffic-type 126 :offset-assert 1024) ) :method-count-assert 27 :size-assert #x47e @@ -48980,28 +49072,29 @@ (traffic-tracker-method-9 (_type_) none 9) (traffic-tracker-method-10 (_type_) none 10) (traffic-tracker-method-11 (_type_) none 11) - (traffic-tracker-method-12 (_type_ uint handle) none 12) - (traffic-tracker-method-13 (_type_ int) handle 13) - (traffic-tracker-method-14 (_type_ int handle) none 14) - (traffic-tracker-method-15 (_type_ int) handle 15) - (traffic-tracker-method-16 (_type_ int handle) handle 16) - (traffic-tracker-method-17 (_type_ int handle) none 17) - (traffic-tracker-method-18 (_type_ process) none 18) - (traffic-tracker-method-19 (_type_ handle) none 19) - (traffic-tracker-method-20 (_type_ int symbol) none 20) - (traffic-tracker-method-21 (_type_ traffic-object-spawn-params) none 21) - (traffic-tracker-method-22 (_type_ int nav-segment float) none 22) - (traffic-tracker-method-23 (_type_ traffic-object-spawn-params) none 23) - (traffic-tracker-method-24 (_type_ uint traffic-engine) none 24) - (traffic-tracker-method-25 (_type_ (function process-focusable traffic-object-type-info none)) none 25) - (traffic-tracker-method-26 (_type_ int (function process-tree none)) none 26) + (add-active-process "Add a process as active." (_type_ traffic-type handle) none 12) + (remove-active-process "Remove a process from the tracking list." (_type_ int) handle 13) + (add-reserved-process "Add a process to the reserve list for a type. This process is allocated, but not yet activated." (_type_ traffic-type handle) none 14) + (get-from-inactive-by-type "Get any handle from the inactive list of this type, and remove it from the list." (_type_ traffic-type) handle 15) + (get-from-inactive-by-handle "Remove the given handle from the inactive list of the given type." (_type_ traffic-type handle) handle 16) + (deactivate-object "Send a traffic-off event (or traffic-off-force) to deactivate an object, specified by index in active object array. + Process is recycled and moved to reserved, if it deactivates." (_type_ int symbol) none 17) + (set-process-to-killed "Move from active to killed. Separate from reserve." (_type_ process) none 18) + (deactivate-all "Deactivate all processes that are tracked" (_type_ symbol) none 19) + (deactivate-all-of-type "Deactivate all processes of given type" (_type_ traffic-type symbol) none 20) + (activate-from-params "Get a reserved process, and activate with the given params." (_type_ traffic-object-spawn-params) none 21) + (activate-by-type "If possible, activate a process of the given type." (_type_ traffic-type nav-segment float) none 22) + (activate-by-handle "Activate, using the handle in the params." (_type_ traffic-object-spawn-params) none 23) + (reset (_type_ uint traffic-engine) none 24) + (for-all-active-processes "Call the given function on all active processes." (_type_ (function process-focusable traffic-object-type-info none)) none 25) + (for-all-active-processes-of-type "Call the given function on all active processes matching the given type." (_type_ traffic-type (function process-focusable traffic-object-type-info none)) none 26) ) ) (declare-type traffic-find-segment-struct structure) (deftype traffic-engine (basic) ((object-hash spatial-hash :offset-assert 4) ;; either spatial-hash is wrong, or this is wrong - (manager uint64 :offset-assert 8) + (manager handle :offset-assert 8) (inv-density-factor float :offset-assert 16) (sync-clock uint8 :offset-assert 20) (sync-mask-8 uint8 :offset-assert 21) @@ -49013,6 +49106,8 @@ (level-data-array traffic-level-data 2 :inline :offset-assert 1040) (object-type-info-array traffic-object-type-info 21 :inline :offset-assert 5200) (tracker-array traffic-tracker 2 :inline :offset-assert 5872) + (citizen-tracker-array traffic-tracker :inline :offset 5872 :score 1) + (vehicle-tracker-array traffic-tracker :inline :offset 7024 :score 1) (inactive-object-array handle 420 :offset-assert 8176) (suppressor traffic-suppressor :inline :offset-assert 11536) (danger-sphere-count int8 :offset-assert 12096) @@ -49025,33 +49120,34 @@ (:methods ;; NOTE - most of these names were taken from the symbols for the event-handler that calls them ;; they may be wrong or misleading as a result, but they are a decent placeholder _for now_ - (traffic-engine-method-9 (_type_) none 9) - (traffic-engine-method-10 (_type_ process) none 10) - (traffic-engine-method-11 (_type_) none 11) - (traffic-engine-method-12 (_type_) none 12) - (add-object (_type_ int process) none 13) - (traffic-engine-method-14 (_type_ object object) symbol 14) - (traffic-engine-method-15 (_type_ nav-segment float) none 15) - (traffic-engine-method-16 (_type_ nav-segment float) none 16) - (traffic-engine-method-17 (_type_ nav-branch) symbol 17) - (child-killed (_type_ process) none 18) - (traffic-engine-method-19 (_type_ object) none 19) - (traffic-engine-method-20 (_type_ vector vector int) nav-segment 20) - (traffic-engine-method-21 (_type_ vector int traffic-find-segment-struct function) none 21) - (add-danger-sphere (_type_ traffic-danger-info) none 22) - (traffic-engine-method-23 (_type_) none 23) + (new (symbol type) _type_ 0) + (update-traffic (_type_) none 9) + (reset-and-init-from-manager "Reset the traffic engine" (_type_ process) none 10) + (stop-alarm-sound (_type_) none 11) + (debug-unused (_type_) none 12) + (add-object (_type_ traffic-type process) none 13) + (sphere-in-loaded-city-infos? (_type_ int vector) symbol 14) + (activate-one-citizen (_type_ nav-segment float) none 15) + (activate-one-vehicle (_type_ nav-segment float) none 16) + (can-dest-be-used? (_type_ nav-branch) symbol 17) + (child-killed "handle killing a child process" (_type_ process) none 18) + (deactivate-all-from-level (_type_ symbol) none 19) + (find-best-segment (_type_ vector vector int) nav-segment 20) + (callback-on-nav-segments-in-sphere (_type_ vector int traffic-find-segment-struct (function traffic-find-segment-struct nav-segment none)) none 21) + (add-danger "Add a danger sphere and suppression box." (_type_ traffic-danger-info) none 22) + (guard-count (_type_) int 23) (set-target-level (_type_ float) none 24) (set-guard-target-level (_type_ float) none 25) (deactivate-all (_type_) none 26) - (deactivate-by-type (_type_ int) none 27) - (traffic-engine-method-28 (_type_) symbol 28) + (deactivate-by-type (_type_ traffic-type) none 27) + (maybe-increase-guard-aim-count (_type_) symbol 28) (restore-default-settings (_type_) none 29) - (increase-alert-level (_type_ object target) none 30) - (decrease-alert-level (_type_ object) none 31) - (set-alert-level (_type_ object) none 32) - (set-max-alert-level (_type_ object) none 33) - (set-alert-duration (_type_ object) none 34) - (get-alert-level (_type_) symbol 35) + (increase-alert-level (_type_ int target) none 30) + (decrease-alert-level (_type_ int) none 31) + (set-alert-level (_type_ int) none 32) + (set-max-alert-level (_type_ int) none 33) + (set-alert-duration (_type_ int) none 34) + (get-alert-level (_type_) int 35) (get-target "@returns [[*target*]]" (_type_) target 36) (set-object-target-level (_type_ int float) none 37) (set-object-target-count (_type_ int int) none 38) @@ -49059,37 +49155,37 @@ (get-object-reserve-count (_type_ int) int 40) (get-object-remaining-count (_type_ int) int 41) (activate-object (_type_ traffic-object-spawn-params) none 42) - (traffic-engine-method-43 (_type_ traffic-object-spawn-params) none 43) - (traffic-engine-method-44 (_type_ int float) none 44) - (traffic-engine-method-45 (_type_) int 45) - (new-suppression-box (_type_ object) none 46) - (traffic-engine-method-47 (_type_ traffic-suppression-params) none 47) + (activate-by-handle (_type_ traffic-object-spawn-params) none 43) + (set-parking-spot-prob (_type_ int float) none 44) + (get-random-parking-spot-type (_type_) traffic-type 45) + (new-suppression-box (_type_ traffic-suppression-params) none 46) + (remove-suppression-box (_type_ traffic-suppression-params) none 47) (update-suppression-box (_type_ traffic-suppression-params) none 48) (traffic-engine-method-49 (_type_ object int traffic-target-status) traffic-target-status 49) - (traffic-engine-method-50 (_type_ process-drawable int) process-focusable 50) - (traffic-engine-method-51 (_type_ (function none)) none 51) - (traffic-engine-method-52 (_type_) none 52) - (end-pursuit-by-type (_type_ int) none 53) + (find-closest-to-with-collide-lists "Iterate through collide lists, find the closest thing to the given process." (_type_ process-drawable collide-spec) process-focusable 50) + (for-all-active-processes (_type_ (function process-focusable traffic-object-type-info none)) none 51) + (send-alert-events (_type_) none 52) + (end-pursuit-by-type (_type_ traffic-type) none 53) (get-traffic-guard-type-settings "TODO - guard-type should be an enum" (_type_ int) traffic-guard-type-settings 54) (get-guard-type-for-traffic-obj "TODO - guard-type should be an enum" (_type_ int) uint 55) (get-traffic-guard-change-to-type "TODO - guard-type should be an enum" (_type_ int) uint 56) (set-guard-target-count-range (_type_ int int int) none 57) - (set-object-auto-activate (_type_ object object) none 58) - (traffic-engine-method-59 (_type_ object int) none 59) - (kill-traffic-sphere (_type_ sphere) none 60) - (level-loaded (_type_ level) none 61) - (level-killed (_type_ level) none 62) + (set-object-auto-activate (_type_ int object) none 58) + (debug-check-proc-in-tracker (_type_ process int) none 59) + (kill-traffic-sphere "Kill everything in the sphere with a traffic-off-force." (_type_ sphere) none 60) + (level-loaded "Call after loading a level to patch the data in the bsp" (_type_ level) none 61) + (level-killed "Call after removing a level. Kills processes and unlinks nav" (_type_ level) none 62) (traffic-engine-method-63 (_type_) none 63) (traffic-engine-method-64 (_type_) none 64) - (traffic-engine-method-65 (_type_ vis-cell) none 65) - (traffic-engine-method-66 (_type_) none 66) - (traffic-engine-method-67 (_type_) none 67) - (traffic-engine-method-68 (_type_) none 68) - (traffic-engine-method-69 (_type_) none 69) - (traffic-engine-method-70 (_type_) none 70) - (traffic-engine-method-71 (_type_) none 71) - (traffic-engine-method-72 (_type_) none 72) - (traffic-engine-method-73 (_type_) none 73) + (handle-new-vis-cell (_type_ vis-cell) none 65) + (update-sync-from-frame-counter (_type_) none 66) + (per-frame-guard-update (_type_) none 67) + (per-frame-activate-deactivate "per-frame activate and deactivate processes." (_type_) none 68) + (per-frame-danger-update "see what's dangerous and make people avoid it." (_type_) none 69) + (update-danger-from-target "make people run away from jak when he is dangerous." (_type_) none 70) + (per-frame-alert-update (_type_) none 71) + (per-frame-suppressor-update (_type_) none 72) + (recompute-supressions (_type_) none 73) ) ) @@ -49447,7 +49543,7 @@ :size-assert #x370 :flag-assert #x9002f00370 (:methods - (rigid-body-object-method-31 (_type_ rigid-body-vehicle-constants) none :replace 31) + (alloc-and-init-rigid-body-control (_type_ rigid-body-vehicle-constants) none :replace 31) (inactive () _type_ :state 53) (waiting () _type_ :state 54) (vehicle-method-55 () _type_ :state 55) @@ -49460,16 +49556,16 @@ (vehicle-method-62 (_type_ float) none 62) (vehicle-method-63 (_type_ float) none 63) (vehicle-method-64 () none 64) - (vehicle-method-65 (_type_) none 65) + (start-jump (_type_) none 65) (vehicle-method-66 () none 66) - (vehicle-method-67 (_type_) none 67) - (vehicle-method-68 (_type_ vector int) none 68) - (vehicle-method-69 (_type_ int) process 69) + (get-seat-count (_type_) int 67) + (compute-seat-position (_type_ vector int) none 68) + (get-rider-in-seat (_type_ int) process 69) (vehicle-method-70 (_type_) process 70) - (vehicle-method-71 (_type_ int process-focusable) none 71) + (put-rider-in-seat (_type_ int process-focusable) none 71) (vehicle-method-72 (_type_) uint 72) - (vehicle-method-73 (_type_ vector int int) int 73) - (vehicle-method-74 (_type_ process) none 74) + (get-best-seat-for-vehicle (_type_ vector int int) int 73) + (remove-rider (_type_ process) none 74) (vehicle-method-75 (_type_) float 75) (vehicle-method-76 (_type_ int uint) none 76) (vehicle-method-77 (_type_) none 77) @@ -49479,9 +49575,9 @@ (vehicle-method-81 (_type_) none 81) (vehicle-method-82 (_type_) none 82) (vehicle-method-83 (_type_) none 83) - (vehicle-method-84 (_type_ vector vector float float) none 84) - (vehicle-method-85 (_type_) none 85) - (vehicle-method-86 () none 86) + (draw-thruster (_type_ vector vector float float) none 84) + (draw-thrusters (_type_) none 85) + (update-joint-mods (_type_) none 86) (vehicle-method-87 (_type_) none 87) (vehicle-method-88 (_type_) none 88) (vehicle-method-89 (_type_) none 89) @@ -49654,12 +49750,12 @@ :size-assert #x20 :flag-assert #xf00000020 (:methods - (xz-height-map-method-9 (_type_ vector) float 9) - (xz-height-map-method-10 (_type_ vector) none 10) - (xz-height-map-method-11 (_type_) none 11) - (xz-height-map-method-12 (_type_ vector) none 12) - (xz-height-map-method-13 (_type_ vector) none 13) - (xz-height-map-method-14 (_type_ vector int) none 14) + (get-height-at-point (_type_ vector) float 9) + (debug-draw-mesh (_type_ vector) none 10) + (debug-print (_type_) none 11) + (debug-draw-at-point (_type_ vector) none 12) + (debug-draw (_type_ vector) none 13) + (debug-add-offset "Add an offset to the given point, likely for debugging purposes." (_type_ vector int) none 14) ) ) @@ -49725,7 +49821,7 @@ ;; nav-graph ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define-extern make-nav-graph (function nav-graph object none)) +(define-extern make-nav-graph (function mysql-nav-graph symbol none)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; vehicle-rider ;; @@ -50032,10 +50128,10 @@ (turret-control-method-9 (_type_ vehicle vector vector) none 9) (turret-control-method-10 (_type_ vehicle) none 10) (turret-control-method-11 (_type_ object object vector) none 11) - (turret-control-method-12 (_type_ joint-mod-rotate-local) none 12) + (update-joint-mod (_type_ joint-mod-rotate-local) none 12) (turret-control-method-13 (_type_) none 13) (turret-control-method-14 (_type_) none 14) - (turret-control-method-15 (_type_ turret-control-info) none 15) + (set-info (_type_ turret-control-info) none 15) (turret-control-method-16 (_type_ float float) none 16) (turret-control-method-17 (_type_ vehicle) none 17) ) @@ -50837,13 +50933,13 @@ ) (deftype bikea (bike-base) - ((fin-fl basic :offset-assert 880) - (fin-fr basic :offset-assert 884) - (fin-rl basic :offset-assert 888) - (fin-rr basic :offset-assert 892) - (rudder basic :offset-assert 896) - (brake-l basic :offset-assert 900) - (brake-r basic :offset-assert 904) + ((fin-fl joint-mod-rotate-local :offset-assert 880) + (fin-fr joint-mod-rotate-local :offset-assert 884) + (fin-rl joint-mod-rotate-local :offset-assert 888) + (fin-rr joint-mod-rotate-local :offset-assert 892) + (rudder joint-mod-rotate-local :offset-assert 896) + (brake-l joint-mod-rotate-local :offset-assert 900) + (brake-r joint-mod-rotate-local :offset-assert 904) ) :method-count-assert 144 :size-assert #x38c @@ -50853,14 +50949,14 @@ ) (deftype bikeb (bike-base) - ((fin-rl basic :offset-assert 880) - (fin-rr basic :offset-assert 884) - (rudder basic :offset-assert 888) - (rudder-f basic :offset-assert 892) - (brake-l basic :offset-assert 896) - (brake-r basic :offset-assert 900) - (flap-l basic :offset-assert 904) - (flap-r basic :offset-assert 908) + ((fin-rl joint-mod-rotate-local :offset-assert 880) + (fin-rr joint-mod-rotate-local :offset-assert 884) + (rudder joint-mod-rotate-local :offset-assert 888) + (rudder-f joint-mod-rotate-local :offset-assert 892) + (brake-l joint-mod-rotate-local :offset-assert 896) + (brake-r joint-mod-rotate-local :offset-assert 900) + (flap-l joint-mod-rotate-local :offset-assert 904) + (flap-r joint-mod-rotate-local :offset-assert 908) ) :method-count-assert 144 :size-assert #x390 @@ -50870,17 +50966,17 @@ ) (deftype bikec (bike-base) - ((fin-fl basic :offset-assert 880) - (fin-fr basic :offset-assert 884) - (fin-rl basic :offset-assert 888) - (fin-rr basic :offset-assert 892) - (fin2-fl basic :offset-assert 896) - (fin2-fr basic :offset-assert 900) - (rudder basic :offset-assert 904) - (brake-l basic :offset-assert 908) - (brake-r basic :offset-assert 912) - (spoiler-l basic :offset-assert 916) - (spoiler-r basic :offset-assert 920) + ((fin-fl joint-mod-rotate-local :offset-assert 880) + (fin-fr joint-mod-rotate-local :offset-assert 884) + (fin-rl joint-mod-rotate-local :offset-assert 888) + (fin-rr joint-mod-rotate-local :offset-assert 892) + (fin2-fl joint-mod-rotate-local :offset-assert 896) + (fin2-fr joint-mod-rotate-local :offset-assert 900) + (rudder joint-mod-rotate-local :offset-assert 904) + (brake-l joint-mod-rotate-local :offset-assert 908) + (brake-r joint-mod-rotate-local :offset-assert 912) + (spoiler-l joint-mod-rotate-local :offset-assert 916) + (spoiler-r joint-mod-rotate-local :offset-assert 920) ) :method-count-assert 144 :size-assert #x39c @@ -50890,7 +50986,7 @@ ) (deftype guard-bike (vehicle-guard) - ((turret-jm basic :offset-assert 1076) + ((turret-jm joint-mod-rotate-local :offset-assert 1076) ) :method-count-assert 159 :size-assert #x438 @@ -50899,12 +50995,12 @@ ) ) -;; (define-extern *bike-explosion-info* vehicle-explosion-info) -;; (define-extern *bikea-constants* object) -;; (define-extern *bikeb-constants* object) -;; (define-extern *bikec-constants* object) -;; (define-extern *guard-bike-constants* object) -;; (define-extern *guard-bike-turret-control-info* object) +(define-extern *bike-explosion-info* vehicle-explosion-info) +(define-extern *bikea-constants* rigid-body-vehicle-constants) +(define-extern *bikeb-constants* rigid-body-vehicle-constants) +(define-extern *bikec-constants* rigid-body-vehicle-constants) +(define-extern *guard-bike-constants* rigid-body-vehicle-constants) +(define-extern *guard-bike-turret-control-info* turret-control-info) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; car ;; @@ -50921,15 +51017,15 @@ ) (deftype cara (car-base) - ((steering-wheel-l basic :offset-assert 884) - (steering-wheel-r basic :offset-assert 888) - (fin-fl basic :offset-assert 892) - (fin-fr basic :offset-assert 896) - (fin-rl basic :offset-assert 900) - (fin-rr basic :offset-assert 904) - (rudder-l basic :offset-assert 908) - (rudder-r basic :offset-assert 912) - (rudder basic :offset-assert 916) + ((steering-wheel-l joint-mod-rotate-local :offset-assert 884) + (steering-wheel-r joint-mod-rotate-local :offset-assert 888) + (fin-fl joint-mod-rotate-local :offset-assert 892) + (fin-fr joint-mod-rotate-local :offset-assert 896) + (fin-rl joint-mod-rotate-local :offset-assert 900) + (fin-rr joint-mod-rotate-local :offset-assert 904) + (rudder-l joint-mod-rotate-local :offset-assert 908) + (rudder-r joint-mod-rotate-local :offset-assert 912) + (rudder joint-mod-rotate-local :offset-assert 916) ) :method-count-assert 144 :size-assert #x398 @@ -50939,12 +51035,12 @@ ) (deftype carb (car-base) - ((steering-wheel-l basic :offset-assert 884) - (steering-wheel-r basic :offset-assert 888) - (fin-fl basic :offset-assert 892) - (fin-fr basic :offset-assert 896) - (fin-rl basic :offset-assert 900) - (fin-rr basic :offset-assert 904) + ((steering-wheel-l joint-mod-rotate-local :offset-assert 884) + (steering-wheel-r joint-mod-rotate-local :offset-assert 888) + (fin-fl joint-mod-rotate-local :offset-assert 892) + (fin-fr joint-mod-rotate-local :offset-assert 896) + (fin-rl joint-mod-rotate-local :offset-assert 900) + (fin-rr joint-mod-rotate-local :offset-assert 904) ) :method-count-assert 144 :size-assert #x38c @@ -50954,13 +51050,13 @@ ) (deftype carc (car-base) - ((steering-wheel basic :offset-assert 884) - (fin-fl basic :offset-assert 888) - (fin-fr basic :offset-assert 892) - (fin-rl basic :offset-assert 896) - (fin-rr basic :offset-assert 900) - (fin2-rl basic :offset-assert 904) - (fin2-rr basic :offset-assert 908) + ((steering-wheel joint-mod-rotate-local :offset-assert 884) + (fin-fl joint-mod-rotate-local :offset-assert 888) + (fin-fr joint-mod-rotate-local :offset-assert 892) + (fin-rl joint-mod-rotate-local :offset-assert 896) + (fin-rr joint-mod-rotate-local :offset-assert 900) + (fin2-rl joint-mod-rotate-local :offset-assert 904) + (fin2-rr joint-mod-rotate-local :offset-assert 908) ) :method-count-assert 144 :size-assert #x390 @@ -50970,7 +51066,7 @@ ) (deftype hellcat (vehicle-guard) - ((turret-jm basic :offset-assert 1076) + ((turret-jm joint-mod-rotate-local :offset-assert 1076) ) :method-count-assert 159 :size-assert #x438 @@ -50979,12 +51075,12 @@ ) ) -;; (define-extern *car-explosion-info* vehicle-explosion-info) -;; (define-extern *cara-constants* object) -;; (define-extern *carb-constants* object) -;; (define-extern *carc-constants* object) -;; (define-extern *hellcat-constants* object) -;; (define-extern *hellcat-front-turret-control-info* object) +(define-extern *car-explosion-info* vehicle-explosion-info) +(define-extern *cara-constants* rigid-body-vehicle-constants) +(define-extern *carb-constants* rigid-body-vehicle-constants) +(define-extern *carc-constants* rigid-body-vehicle-constants) +(define-extern *hellcat-constants* rigid-body-vehicle-constants) +(define-extern *hellcat-front-turret-control-info* turret-control-info) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; test-bike ;; @@ -51008,8 +51104,8 @@ ) ) -;; (define-extern *test-bike-constants* object) -;; (define-extern *evan-test-bike-constants* object) +(define-extern *test-bike-constants* rigid-body-vehicle-constants) +(define-extern *evan-test-bike-constants* rigid-body-vehicle-constants) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; test-car ;; @@ -51024,7 +51120,7 @@ ) ) -;; (define-extern *test-car-constants* object) +(define-extern *test-car-constants* rigid-body-vehicle-constants) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; citizen ;; @@ -51471,7 +51567,7 @@ (define-extern *traffic-suppress-activation* symbol) (define-extern *mysql-nav-graph* mysql-nav-graph) (define-extern *traffic-rigid-body-queue* rigid-body-queue) -(define-extern get-level-nav-graph-by-id (function object symbol)) +(define-extern get-level-nav-graph-by-id "Get the nav-graph with the given ID from any of the currently loaded levels" (function int nav-graph)) (define-extern add-debug-line-arrow "Does nothing!" (function none)) (define-extern traffic-los-clear? (function vector vector symbol)) (define-extern *guard-target-spots* (array vector)) @@ -52014,11 +52110,11 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-extern *pilot-mods* surface) -;; (define-extern target-pilot-handler function) -;; (define-extern target-pilot-pidax-enter function) -;; (define-extern target-pilot-pidax-exit function) -;; (define-extern target-pilot-exit function) -;; (define-extern target-pilot-init function) +(define-extern target-pilot-handler (function process int symbol event-message-block object :behavior target)) +(define-extern target-pilot-pidax-enter (function object :behavior target)) +(define-extern target-pilot-pidax-exit (function object :behavior target)) +(define-extern target-pilot-exit (function object :behavior target)) +(define-extern target-pilot-init (function handle symbol object :behavior target)) (define-extern pilot-on-ground? (function symbol :behavior target)) (define-extern target-pilot-post (function none :behavior target)) @@ -52026,21 +52122,13 @@ ;; pilot-states ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; (define-extern target-pilot-bike-anim-loop function) -;; (define-extern target-pilot-car-anim-loop function) -;; (define-extern target-daxter-pilot-car-anim-loop function) -;; (define-extern target-pilot-trans function) -;; (define-extern target-pilot-signal-ready function) -;; (define-extern target-pilot-stance state) -;; (define-extern target-pilot-impact state) -;; (define-extern *pilot-get-on-mods* object) -;; (define-extern target-pilot-get-on state) -;; (define-extern *pilot-get-off-mods* object) -;; (define-extern target-pilot-get-off state) -;; (define-extern target-pilot-grab state) -;; (define-extern target-pilot-clone-anim state) -;; (define-extern target-pilot-hit state) -;; (define-extern target-pilot-death state) +(define-extern target-pilot-bike-anim-loop (function none :behavior target)) +(define-extern target-pilot-car-anim-loop (function none :behavior target)) +(define-extern target-daxter-pilot-car-anim-loop (function none :behavior target)) +(define-extern target-pilot-trans (function none :behavior target)) +(define-extern target-pilot-signal-ready (function object :behavior target)) +(define-extern *pilot-get-on-mods* surface) +(define-extern *pilot-get-off-mods* surface) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; kid-h ;; diff --git a/decompiler/config/jak2/anonymous_function_types.jsonc b/decompiler/config/jak2/anonymous_function_types.jsonc index be903bb6da..ea1251e2f9 100644 --- a/decompiler/config/jak2/anonymous_function_types.jsonc +++ b/decompiler/config/jak2/anonymous_function_types.jsonc @@ -720,7 +720,7 @@ [35, "(function process-focusable traffic-object-type-info none)"], [36, "(function process-focusable traffic-object-type-info none)"], [45, "(function process-tree none)"], - [61, "(function vector matrix matrix)"] // a guess + [61, "(function traffic-find-segment-struct nav-segment none)"] // a guess ], "ruins-obs": [ [0, "(function object :behavior task-manager)"], @@ -1170,5 +1170,8 @@ [11, "(function int int form-search-info uint)"], [14, "(function vector object)"], [15, "(function int int (pointer object) int)"] + ], + "pilot-states": [ + [15, "(function object object object int none)"] ] } diff --git a/decompiler/config/jak2/hacks.jsonc b/decompiler/config/jak2/hacks.jsonc index a2249a2bde..eb0695723b 100644 --- a/decompiler/config/jak2/hacks.jsonc +++ b/decompiler/config/jak2/hacks.jsonc @@ -503,7 +503,7 @@ 2, 3, 7, 10, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 25, 26, 30 ], "(method 10 simple-sprite-system)": [0, 1, 3, 4, 5, 6, 9, 11], - "target-pilot-post": [0, 2, 4, 5, 13, 16, 22, 27, 41], + "target-pilot-post": [0, 2, 4, 13, 16, 22, 27, 41], "(anon-function 0 ruins-obs)": [ 0, 5, 7, 12, 13, 15, 17, 23, 24, 33, 42, 45, 46, 53, 58 ], diff --git a/decompiler/config/jak2/label_types.jsonc b/decompiler/config/jak2/label_types.jsonc index 10e745e32f..8e0ec74cba 100644 --- a/decompiler/config/jak2/label_types.jsonc +++ b/decompiler/config/jak2/label_types.jsonc @@ -1013,7 +1013,8 @@ ], "traffic-engine": [ ["L803", "uint64", true], - ["L733", "uint64", true] + ["L733", "uint64", true], + ["L734", "uint64", true] ], "mechtest-obs": [["L79", "attack-info"]], "pillar-collapse": [["L193", "attack-info"]], @@ -1530,5 +1531,10 @@ ["L591", "uint64", true], ["L592", "uint64", true], ["L590", "uint64", true] + ], + "bike": [ + ["L63", "(inline-array vector)", 2], + ["L64", "(inline-array vector)", 2] + ] } diff --git a/decompiler/config/jak2/stack_structures.jsonc b/decompiler/config/jak2/stack_structures.jsonc index 119876f748..769ccd16b0 100644 --- a/decompiler/config/jak2/stack_structures.jsonc +++ b/decompiler/config/jak2/stack_structures.jsonc @@ -1535,7 +1535,7 @@ "(method 29 vehicle)": [ [16, ["inline-array", "matrix", 9]], [640, ["inline-array", "vector", 5]], - [736, ["inline-array", "vehicle-control-point", 2]] + [736, ["inline-array", "vehicle-control-point", 24]] ], "vehicle-guard-choose-branch": [[16, ["inline-array", "vector", 5]]], "(method 155 vehicle-guard)": [ @@ -1543,9 +1543,10 @@ [256, "turret-unknown-stack-structure2"] ], "(method 70 traffic-engine)": [ - [16, ["inline-array", "traffic-suppression-box", 2]] + [16, ["inline-array", "traffic-suppression-box", 2]], + [80, ["array", "collide-shape", 40]] ], - "(method 22 traffic-engine)": [[16, "pilot-edge-grab-info"]], + "(method 22 traffic-engine)": [[16, "traffic-suppression-params"]], "(method 14 traffic-level-data)": [ [32, "vector"], [48, "vector"], @@ -1944,5 +1945,24 @@ ], "(post draw-closest-minimap nav-graph-editor)": [ [16, ["inline-array", "vector", 5]] + ], + "(method 69 traffic-engine)": [ + [16, ["array", "collide-shape", 40]] + ], + "(method 60 traffic-engine)": [ + [16, ["array", "collide-shape", 64]] + ], + "(method 85 bike-base)": [ + [16, ["inline-array", "matrix", 3]] + ], + "target-pilot-post": [ + [48, "collide-query-with-5vec"], + [640, "matrix"] + ], + "target-pilot-trans": [ + [16, ["inline-array", "vector", 10]] + ], + "(code target-pilot-get-off)": [ + [96, ["inline-array", "vector", 10]] ] } diff --git a/decompiler/config/jak2/type_casts.jsonc b/decompiler/config/jak2/type_casts.jsonc index a9d9e37383..40ea3e565a 100644 --- a/decompiler/config/jak2/type_casts.jsonc +++ b/decompiler/config/jak2/type_casts.jsonc @@ -6905,7 +6905,8 @@ [321, "s2", "nav-segment"], [327, "s2", "nav-segment"], [[159, 191], "s3", "process-focusable"], - [[89, 125], "s3", "vehicle"] + [[89, 125], "s3", "vehicle"], + [16, "v1", "(pointer uint128)"] ], "(method 50 traffic-engine)": [ [13, "v1", "connection"], @@ -8980,5 +8981,122 @@ [49, "a0", "(pointer int32)"], [51, "a0", "(array object)"] ], - "(method 7 nav-graph-editor)": [[9, "t9", "(function process int none)"]] + "(method 7 nav-graph-editor)": [[9, "t9", "(function process int none)"]], + "(method 18 traffic-tracker)": [ + [[8, 12], "a1", "handle"], + [[11, 19], "a0", "handle"] + ], + "(method 10 traffic-engine)": [ + [102, "v1", "(pointer uint128)"] + ], + "(method 61 traffic-engine)": [ + [95, "t0", "uint"], + [111, "a2", "uint"], + [79, "a3", "uint"], + [64, "a3", "uint"], + [48, "t0", "uint"] + ], + "(method 9 xz-height-map)": [ + [36, "a2", "pointer"], + [[37, 49], "a1", "(pointer int8)"] + ], + "(method 10 xz-height-map)": [ + [121, "s0", "pointer"] + ], + "(method 42 nav-graph)": [ + [27, "v1", "uint"] + ], + "make-nav-graph": [ + [[28, 31], "v1", "mysql-nav-graph-level-info"], + [31, "v1", "mysql-nav-graph-level-info"] + ], + "(method 44 nav-graph)": [ + [[102, 125], "s0", "mysql-nav-edge"], + [144, "s0", "mysql-nav-edge"], + [236, "s0", "mysql-nav-edge"], + [246, "v1", "mysql-nav-edge"], + [254, "v1", "mysql-nav-edge"] + ], + "(method 11 city-level-info)": [ + [27, "a3", "(pointer int8)"] + ], + "(method 36 bike-base)": [ + [7, "t9", "(function object none)"] + ], + "(method 85 bike-base)": [ + [7, "t9", "(function object none)"], + [[22, 26], "v1", "(pointer uint128)"] + ], + "(method 7 bikea)": [ + [44, "t9", "(function object int bikea)"] + ], + "(method 7 bikeb)": [ + [49, "t9", "(function object int bikeb)"] + ], + "(method 7 bikec)": [ + [64, "t9", "(function object int bikec)"] + ], + "(method 7 guard-bike)": [ + [14, "t9", "(function object int guard-bike)"] + ], + "target-pilot-exit": [ + [64, "gp", "vehicle"] + ], + "target-pilot-init": [ + [[61, 68], "s4", "vehicle"], + [[68, 138], "s4", "vehicle"] + ], + "target-pilot-post": [ + [[96, 114], "s5", "vehicle"], + [[279, 294], "s5", "vehicle"] + ], + "target-pilot-trans": [ + [[53, 130], "s5", "vehicle"] + ], + "(code target-pilot-impact)": [ + [83, "v1", "art-joint-anim"], + [138, "v1", "art-joint-anim"], + [192, "v1", "art-joint-anim"], + [247, "v1", "art-joint-anim"], + [300, "v1", "art-joint-anim"], + [363, "v1", "art-joint-anim"], + [418, "v1", "art-joint-anim"], + [472, "v1", "art-joint-anim"], + [532, "v1", "art-joint-anim"], + [590, "v1", "art-joint-anim"], + [655, "v1", "art-joint-anim"], + [710, "v1", "art-joint-anim"], + [764, "v1", "art-joint-anim"], + [824, "v1", "art-joint-anim"], + [882, "v1", "art-joint-anim"] + ], + "(trans target-pilot-get-on)": [ + [[28, 48], "gp", "vehicle"] + ], + "(code target-pilot-get-on)": [ + [65, "gp", "art-joint-anim"], + [173, "a1", "vehicle"] + ], + "(event target-pilot-grab)": [ + [24, "a0", "process"] + ], + "(enter target-pilot-edge-grab)": [ + [[40, 46], "a0", "process-focusable"] + ], + "target-pilot-handler": [ + [[28, 33], "a0", "vehicle"], + [103, "a0", "process"] + ], + "(method 7 cara)": [ + [54, "t9", "(function object object cara)"] + ], + "(method 7 carb)": [ + [39, "t9", "(function object object carb)"] + ], + "(method 7 carc)": [ + [44, "t9", "(function object object carb)"] + ], + "(method 7 hellcat)": [ + [14, "t9", "(function object object hellcat)"] + ] } diff --git a/goal_src/jak2/engine/ai/traffic-h.gc b/goal_src/jak2/engine/ai/traffic-h.gc index 77049042ca..71defc14c0 100644 --- a/goal_src/jak2/engine/ai/traffic-h.gc +++ b/goal_src/jak2/engine/ai/traffic-h.gc @@ -26,6 +26,30 @@ ) ;; ---traffic-danger-flags +;; +++traffic-h:traffic-type +(defenum traffic-type + :type uint8 + (citizen-norm-1 0) + (citizen-chick 1) + (citizen-fat 2) + (citizen-norm-2 3) + (crimson-guard-0 4) + (crimson-guard-1 6) + (crimson-guard-2 7) + (metalhead-grunt 8) + (metalhead-flitter 9) + (metalhead-predator 10) + (bikea 11) + (bikeb 12) + (bikec 13) + (cara 14) + (carb 15) + (carc 16) + (guard-bike 18) + (hellcat 19) + ) +;; ---traffic-h:traffic-type + ;; NOTE - for default-menu (define-extern traffic-start (function none)) (define-extern traffic-kill (function none)) @@ -33,6 +57,8 @@ ;; NOTE - for vehicle-rider (define-extern lwide-entity-hack (function none)) +(define-extern *traffic-alert-level-force* symbol) + (declare-type nav-mesh basic) (declare-type nav-branch structure) @@ -46,6 +72,7 @@ (define *race-vehicle-entity* (the-as object #f)) + (deftype traffic-danger-info (structure) ((sphere sphere :inline :offset-assert 0) (velocity vector :inline :offset-assert 16) @@ -71,10 +98,10 @@ :size-assert #x29 :flag-assert #xd00000029 (:methods - (traffic-suppression-params-method-9 (_type_) symbol 9) - (traffic-suppression-params-method-10 (_type_) symbol 10) + (try-creating-new-suppression-box (_type_) symbol 9) + (create-or-update-suppression-box (_type_) symbol 10) (has-valid-id? (_type_) none 11) - (traffic-suppression-params-method-12 (_type_) none 12) + (kill-suppression-box (_type_) none 12) ) ) @@ -86,21 +113,29 @@ ) (deftype traffic-object-spawn-params (structure) - ((object-type uint8 :offset-assert 0) - (behavior uint64 :offset-assert 8) - (id uint32 :offset-assert 16) - (nav-mesh nav-mesh :offset-assert 20) - (nav-branch nav-branch :offset-assert 24) - (position vector :inline :offset-assert 32) - (rotation quaternion :inline :offset-assert 48) - (velocity vector :inline :offset-assert 64) - (handle uint64 :offset-assert 80) - (guard-type uint8 :offset-assert 88) - (user-data uint32 :offset-assert 92) - (flags uint32 :offset-assert 96) - (proc process :offset-assert 100) + ((object-type traffic-type :offset-assert 0) + (behavior uint64 :offset-assert 8) + (id uint32 :offset-assert 16) + (nav-mesh nav-mesh :offset-assert 20) + (nav-branch nav-branch :offset-assert 24) + (position vector :inline :offset-assert 32) + (rotation quaternion :inline :offset-assert 48) + (velocity vector :inline :offset-assert 64) + (handle uint64 :offset-assert 80) + (guard-type uint8 :offset-assert 88) + (user-data uint32 :offset-assert 92) + (flags uint32 :offset-assert 96) + (proc process :offset-assert 100) ) :method-count-assert 9 :size-assert #x68 :flag-assert #x900000068 ) + +(deftype mystery-traffic-object-spawn-params (structure) + "TODO - what is this!" + ((params traffic-object-spawn-params :inline :offset-assert 0) + (vector vector 3 :inline :offset-assert 112) + )) + +(define-extern traffic-object-spawn (function process traffic-object-spawn-params process-drawable)) diff --git a/goal_src/jak2/engine/anim/joint-exploder.gc b/goal_src/jak2/engine/anim/joint-exploder.gc index a6da3dc0c9..a064d7d382 100644 --- a/goal_src/jak2/engine/anim/joint-exploder.gc +++ b/goal_src/jak2/engine/anim/joint-exploder.gc @@ -49,7 +49,7 @@ (deftype joint-exploder-static-params (basic) ((joints (array joint-exploder-static-joint-params) :offset-assert 4) (collide-spec uint32 :offset-assert 8) - (art-level basic :offset-assert 12) + (art-level symbol :offset-assert 12) ) :method-count-assert 9 :size-assert #x10 diff --git a/goal_src/jak2/engine/common_objs/rigid-body-plat.gc b/goal_src/jak2/engine/common_objs/rigid-body-plat.gc index 0a75219690..aeb69bc4ac 100644 --- a/goal_src/jak2/engine/common_objs/rigid-body-plat.gc +++ b/goal_src/jak2/engine/common_objs/rigid-body-plat.gc @@ -346,7 +346,7 @@ (none) ) -(defmethod rigid-body-object-method-31 rigid-body-platform ((obj rigid-body-platform) (arg0 rigid-body-object-constants)) +(defmethod alloc-and-init-rigid-body-control rigid-body-platform ((obj rigid-body-platform) (arg0 rigid-body-object-constants)) (with-pp (set! (-> obj info-override) (the-as rigid-body-platform-constants arg0)) (set! (-> obj rbody) (new 'process 'rigid-body-control obj)) @@ -374,7 +374,7 @@ ) ) -(defmethod rigid-body-object-method-32 rigid-body-platform ((obj rigid-body-platform)) +(defmethod allocate-and-init-cshape rigid-body-platform ((obj rigid-body-platform)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -436,9 +436,9 @@ ) ) -(defmethod rigid-body-object-method-33 rigid-body-platform ((obj rigid-body-platform)) +(defmethod init-skel-and-rigid-body rigid-body-platform ((obj rigid-body-platform)) (set! (-> obj float-height-offset) 0.0) - (rigid-body-object-method-31 obj *rigid-body-platform-constants*) + (alloc-and-init-rigid-body-control obj *rigid-body-platform-constants*) (let ((s5-0 (-> obj info-override control-point-count))) (dotimes (s4-0 s5-0) (let ((s3-0 (-> obj control-point-array data s4-0))) @@ -463,9 +463,9 @@ This commonly includes things such as: - loading the skeleton group / bones - sounds" (set! (-> obj mask) (logior (process-mask platform) (-> obj mask))) - (rigid-body-object-method-32 obj) + (allocate-and-init-cshape obj) (process-drawable-from-entity! obj arg0) - (rigid-body-object-method-33 obj) + (init-skel-and-rigid-body obj) (rigid-body-object-method-34 obj) 0 (none) diff --git a/goal_src/jak2/engine/debug/nav/mysql-nav-graph.gc b/goal_src/jak2/engine/debug/nav/mysql-nav-graph.gc index 534ac8bfad..d47dce2273 100644 --- a/goal_src/jak2/engine/debug/nav/mysql-nav-graph.gc +++ b/goal_src/jak2/engine/debug/nav/mysql-nav-graph.gc @@ -140,7 +140,7 @@ (width float :offset-assert 60) (minimap_edge_flag nav-minimap-edge-flag :offset-assert 64) ) - :pack-me + :allow-misaligned :method-count-assert 10 :size-assert #x44 :flag-assert #xa00000044 @@ -191,7 +191,7 @@ (set! (-> mysql-nav-visnode-array heap-base) (the-as uint 32)) (deftype mysql-nav-graph-level-info (structure) - ((level string :offset-assert 0) + ((level symbol :offset-assert 0) (level-id uint32 :offset-assert 4) (node-count int32 :offset-assert 8) (branch-count int32 :offset-assert 12) @@ -293,7 +293,7 @@ otherwise, return the new size of the array" -1 ) (else - (let ((v1-5 (the-as mysql-nav-edge (+ (+ (* 80 (-> obj edge-array length)) 12) (the-as int (-> obj edge-array))))) + (let ((v1-5 (-> obj edge-array data (-> obj edge-array length))) (v0-1 (-> obj edge-array length)) ) (+! (-> obj edge-array length) 1) @@ -735,7 +735,7 @@ returns `-1` if none is found" "Iterate through the `edge-array` and return the index for the first [[mysql-nav-edge]] whom's `nav_edge_id` matches the provided id returns `-1` if none is found" (dotimes (v1-0 (-> obj edge-array length)) - (if (= edge-id (-> (the-as mysql-nav-edge (+ (+ (* 80 v1-0) 12) (the-as int (-> obj edge-array)))) nav_edge_id)) + (if (= edge-id (-> (the-as mysql-nav-edge (-> obj edge-array data v1-0)) nav_edge_id)) (return v1-0) ) ) @@ -875,10 +875,7 @@ returns `-1` if none is found" (set! sv-32 (string->int (-> s3-3 data (+ s2-2 2)))) (set! sv-48 (indexof-nav-node obj s0-2)) (set! sv-64 (indexof-nav-node obj sv-32)) - (let ((nav-edge - (the-as mysql-nav-edge (+ (+ (* 80 (-> obj edge-array length)) 12) (the-as int (-> obj edge-array)))) - ) - ) + (let ((nav-edge (-> obj edge-array data (-> obj edge-array length)))) (when (and (!= sv-48 -1) (!= sv-64 -1)) (set! (-> nav-edge nav_graph_id) (-> obj nav_graph_id)) (set! (-> nav-edge nav_edge_id) (the-as uint (string->int (-> s3-3 data s2-2)))) @@ -1104,10 +1101,10 @@ returns `-1` if none is found" ) ) (dotimes (v1-3 (-> obj edge-array length)) - (set! (-> (the-as mysql-nav-edge (+ (+ (* 80 v1-3) 12) (the-as int (-> obj edge-array)))) temp-next-edge) #f) + (set! (-> (the-as mysql-nav-edge (-> obj edge-array data v1-3)) temp-next-edge) #f) ) (countdown (v1-7 (-> obj edge-array length)) - (let ((a1-17 (the-as mysql-nav-edge (+ (+ (* 80 v1-7) 12) (the-as int (-> obj edge-array)))))) + (let ((a1-17 (-> obj edge-array data v1-7))) (when (not (logtest? (-> a1-17 mysql-save-flag) (mysql-save-flag delete))) (let ((a2-8 (-> obj node-array data (-> a1-17 runtime-node-id-1)))) (when (not (logtest? (-> a2-8 mysql-save-flag) (mysql-save-flag delete))) @@ -1166,7 +1163,7 @@ returns `-1` if none is found" (set! (-> obj level-info-last-lookup) v1-9) ) (set! s5-0 (-> obj level-info-array v1-9)) - (set! (-> s5-0 level) (the-as string (-> arg0 level_name))) + (set! (-> s5-0 level) (-> arg0 level_name)) (set! (-> s5-0 node-count) 0) (+! (-> obj level-info-array-length) 1) ) diff --git a/goal_src/jak2/engine/debug/nav/nav-graph-editor.gc b/goal_src/jak2/engine/debug/nav/nav-graph-editor.gc index d44123c56f..b193947131 100644 --- a/goal_src/jak2/engine/debug/nav/nav-graph-editor.gc +++ b/goal_src/jak2/engine/debug/nav/nav-graph-editor.gc @@ -13,6 +13,8 @@ ;; DECOMP BEGINS + + (deftype nav-graph-command (structure) ((com-type uint32 :offset-assert 0) ;; TODO - enum (id int32 :offset-assert 4) @@ -117,3 +119,9 @@ (nav-graph-editor-method-63 (_type_) none 63) ) ) + +;; hack +;; stub +(defun get-nav-graph-editor () + (the nav-graph-editor #f) + ) \ No newline at end of file diff --git a/goal_src/jak2/engine/game/pilot-h.gc b/goal_src/jak2/engine/game/pilot-h.gc index 5507f41814..2618cdfe22 100644 --- a/goal_src/jak2/engine/game/pilot-h.gc +++ b/goal_src/jak2/engine/game/pilot-h.gc @@ -33,7 +33,7 @@ (seat-index int8 :offset-assert 41) (backup-nav-radius float :offset-assert 44) (cam-side-shift float :offset-assert 48) - (enable-cam-side-shift basic :offset-assert 52) + (enable-cam-side-shift symbol :offset-assert 52) (gun? symbol :offset-assert 56) (controls vehicle-controls :inline :offset-assert 60) (accel-array vector 8 :inline :offset-assert 80) diff --git a/goal_src/jak2/engine/level/bsp-h.gc b/goal_src/jak2/engine/level/bsp-h.gc index 8ab9bf7c41..070bb07c0e 100644 --- a/goal_src/jak2/engine/level/bsp-h.gc +++ b/goal_src/jak2/engine/level/bsp-h.gc @@ -11,6 +11,7 @@ (declare-type entity-race-mesh entity) (declare-type entity-nav-mesh entity) (declare-type actor-group basic) +(declare-type city-level-info structure) (defenum texture-page-flag :type uint16 @@ -84,8 +85,7 @@ ;; 200 is some array (wind-array-length int32 :offset 204) - ;; 208 is a structure of some sort - (method 97 vehicle) - (bsp-header-jkh1b23 clock :offset 208) + (city-level-info city-level-info :offset 208) (vis-spheres vector-array :offset 216) diff --git a/goal_src/jak2/engine/physics/rigid-body-h.gc b/goal_src/jak2/engine/physics/rigid-body-h.gc index 50c2826601..8618a19446 100644 --- a/goal_src/jak2/engine/physics/rigid-body-h.gc +++ b/goal_src/jak2/engine/physics/rigid-body-h.gc @@ -332,12 +332,12 @@ (active () _type_ :state 28) (rigid-body-object-method-29 (_type_ float) none 29) (rigid-body-object-method-30 (_type_) none 30) - (rigid-body-object-method-31 (_type_ rigid-body-object-constants) none 31) - (rigid-body-object-method-32 (_type_) none 32) - (rigid-body-object-method-33 (_type_) none 33) + (alloc-and-init-rigid-body-control (_type_ rigid-body-object-constants) none 31) + (allocate-and-init-cshape (_type_) none 32) + (init-skel-and-rigid-body (_type_) none 33) (rigid-body-object-method-34 (_type_) none 34) (rigid-body-object-method-35 (_type_) none 35) - (rigid-body-object-method-36 (_type_) none 36) + (do-engine-sounds (_type_) none 36) (rigid-body-object-method-37 (_type_) none 37) (rigid-body-object-method-38 (_type_) none 38) (rigid-body-object-method-39 (_type_) none 39) diff --git a/goal_src/jak2/engine/physics/rigid-body.gc b/goal_src/jak2/engine/physics/rigid-body.gc index ca011b2ae0..929f6c3150 100644 --- a/goal_src/jak2/engine/physics/rigid-body.gc +++ b/goal_src/jak2/engine/physics/rigid-body.gc @@ -932,7 +932,7 @@ (none) ) -(defmethod rigid-body-object-method-31 rigid-body-object ((obj rigid-body-object) (arg0 rigid-body-object-constants)) +(defmethod alloc-and-init-rigid-body-control rigid-body-object ((obj rigid-body-object) (arg0 rigid-body-object-constants)) (set! (-> obj info) arg0) (set! (-> obj rbody) (new 'process 'rigid-body-control obj)) (update-transforms (-> obj root-override-2)) @@ -954,7 +954,7 @@ (none) ) -(defmethod rigid-body-object-method-32 rigid-body-object ((obj rigid-body-object)) +(defmethod allocate-and-init-cshape rigid-body-object ((obj rigid-body-object)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -1003,8 +1003,8 @@ ) ) -(defmethod rigid-body-object-method-33 rigid-body-object ((obj rigid-body-object)) - (rigid-body-object-method-31 obj *rigid-body-object-constants*) +(defmethod init-skel-and-rigid-body rigid-body-object ((obj rigid-body-object)) + (alloc-and-init-rigid-body-control obj *rigid-body-object-constants*) 0 (none) ) @@ -1016,22 +1016,22 @@ This commonly includes things such as: - collision information - loading the skeleton group / bones - sounds" - (rigid-body-object-method-32 obj) + (allocate-and-init-cshape obj) (process-drawable-from-entity! obj arg0) - (rigid-body-object-method-33 obj) + (init-skel-and-rigid-body obj) (rigid-body-object-method-34 obj) 0 (none) ) -(defmethod rigid-body-object-method-36 rigid-body-object ((obj rigid-body-object)) +(defmethod do-engine-sounds rigid-body-object ((obj rigid-body-object)) 0 (none) ) (defmethod rigid-body-object-method-37 rigid-body-object ((obj rigid-body-object)) (rigid-body-object-method-30 obj) - (rigid-body-object-method-36 obj) + (do-engine-sounds obj) (let ((v1-4 (-> obj rbody)) (a1-0 (-> obj root-override-2)) ) diff --git a/goal_src/jak2/engine/sound/speech-h.gc b/goal_src/jak2/engine/sound/speech-h.gc index 5ef0e09ba6..ac4171f762 100644 --- a/goal_src/jak2/engine/sound/speech-h.gc +++ b/goal_src/jak2/engine/sound/speech-h.gc @@ -25,6 +25,9 @@ (speech-type-1 1) (speech-type-2 2) (speech-type-3 3) + (speech-type-4 4) + (speech-type-5 5) + ) ;; ---speech-type diff --git a/goal_src/jak2/engine/target/target-h.gc b/goal_src/jak2/engine/target/target-h.gc index 1664401907..82ce21b615 100644 --- a/goal_src/jak2/engine/target/target-h.gc +++ b/goal_src/jak2/engine/target/target-h.gc @@ -165,12 +165,10 @@ (define-extern target-powerup-effect (function symbol none :behavior target)) (define-extern target-load-wait (state target)) (define-extern target-board-start (state object target)) -(define-extern target-pilot-start (state handle target)) (define-extern target-mech-start (state handle float symbol target)) (define-extern target-turret-get-on (state handle target)) (define-extern target-play-anim (state string handle target)) (define-extern target-edge-grab (state target)) -(define-extern target-pilot-edge-grab (state target)) (define-extern target-pole-cycle (state handle target)) (define-extern target-slide-down-to-ground (state target)) @@ -363,8 +361,16 @@ target-mech-stance (target-mech-start handle float symbol) target-mech-walk - target-pilot-edge-grab - (target-pilot-start handle) + (target-pilot-clone-anim handle) + (target-pilot-death symbol) + (target-pilot-edge-grab pilot-edge-grab-info) + target-pilot-get-off + target-pilot-get-on + target-pilot-grab + (target-pilot-hit symbol attack-info) + target-pilot-impact + target-pilot-stance + (target-pilot-start handle symbol symbol) (target-play-anim string handle) (target-pole-cycle handle) (target-pole-flip-forward float float float) diff --git a/goal_src/jak2/engine/target/target-handler.gc b/goal_src/jak2/engine/target/target-handler.gc index 12958159f3..c3716d025b 100644 --- a/goal_src/jak2/engine/target/target-handler.gc +++ b/goal_src/jak2/engine/target/target-handler.gc @@ -1217,17 +1217,14 @@ ) ) (when s5-1 - (case (-> arg3 param 0) - (('pilot-daxter 'pilot-race-daxter) - #t - ) - (else - ) - ) - enter-state - (let ((a0-93 (process->handle s5-1))) - (-> arg3 param 3) - (go target-pilot-start (the-as handle a0-93)) + (let* ((v1-83 (-> arg3 param 0)) + (a2-4 (if (or (= v1-83 'pilot-daxter) (= v1-83 'pilot-race-daxter)) + #t + #f + ) + ) + ) + (go target-pilot-start (process->handle s5-1) (the-as symbol (-> arg3 param 3)) a2-4) ) ) ) @@ -1354,9 +1351,7 @@ (label cfg-238) (b! (!= v1-0 'pilot-edge-grab) cfg-242 :delay (nop!)) (b! (logtest? (-> self focus-status) (focus-status dead hit grabbed)) cfg-241 :delay (set! v0-0 #f)) - enter-state - (-> arg3 param 0) - (set! v0-0 (go target-pilot-edge-grab)) + (set! v0-0 (go target-pilot-edge-grab (the-as pilot-edge-grab-info (-> arg3 param 0)))) (label cfg-241) (b! #t cfg-291 :delay (nop!)) (label cfg-242) diff --git a/goal_src/jak2/game.gp b/goal_src/jak2/game.gp index 3725c133c8..930595398b 100644 --- a/goal_src/jak2/game.gp +++ b/goal_src/jak2/game.gp @@ -76,7 +76,7 @@ ;; TODO - can't use a variable because :deps downstream doesn't take a proper list (can't pass it in quoted) ;; (define common-dep ("$OUT/obj/cty-guard-turret-button.o")) - +(cgo-file "cwi.gd" ("$OUT/obj/cty-guard-turret-button.o")) (cgo-file "lmeetbrt.gd" ("$OUT/obj/cty-guard-turret-button.o")) (cgo-file "cta.gd" ("$OUT/obj/cty-guard-turret-button.o")) (cgo-file "palout.gd" ("$OUT/obj/cty-guard-turret-button.o")) @@ -150,7 +150,6 @@ (cgo-file "unb.gd" ("$OUT/obj/cty-guard-turret-button.o")) (cgo-file "cpo.gd" ("$OUT/obj/cty-guard-turret-button.o")) (cgo-file "cap.gd" ("$OUT/obj/cty-guard-turret-button.o")) -(cgo-file "cwi.gd" ("$OUT/obj/cty-guard-turret-button.o")) (cgo-file "lbbush.gd" ("$OUT/obj/cty-guard-turret-button.o")) (cgo-file "lpackage.gd" ("$OUT/obj/cty-guard-turret-button.o")) (cgo-file "ctykora.gd" ("$OUT/obj/cty-guard-turret-button.o")) diff --git a/goal_src/jak2/levels/city/common/bike.gc b/goal_src/jak2/levels/city/common/bike.gc index 4ba7dfe3a8..9cf1ba6ed2 100644 --- a/goal_src/jak2/levels/city/common/bike.gc +++ b/goal_src/jak2/levels/city/common/bike.gc @@ -7,3 +7,1544 @@ ;; DECOMP BEGINS +(defskelgroup skel-bikea bikea bikea-lod0-jg bikea-idle-ja + ((bikea-lod0-mg (meters 20)) (bikea-lod1-mg (meters 40)) (bikea-lod2-mg (meters 999999))) + :bounds (static-spherem 0 0 0 3.4) + :shadow bikea-shadow-mg + :origin-joint-index 3 + ) + +(defskelgroup skel-bikeb bikeb bikeb-lod0-jg bikeb-idle-ja + ((bikeb-lod0-mg (meters 20)) (bikeb-lod1-mg (meters 40)) (bikeb-lod2-mg (meters 999999))) + :bounds (static-spherem 0 0 0 3.4) + :shadow bikeb-shadow-mg + :origin-joint-index 3 + ) + +(defskelgroup skel-bikec bikec bikec-lod0-jg bikec-idle-ja + ((bikec-lod0-mg (meters 20)) (bikec-lod1-mg (meters 40)) (bikec-lod2-mg (meters 999999))) + :bounds (static-spherem 0 0 0 3.8) + :shadow bikec-shadow-mg + :origin-joint-index 3 + ) + +(defskelgroup skel-guard-bike crimson-bike crimson-bike-lod0-jg crimson-bike-idle-ja + ((crimson-bike-lod0-mg (meters 20)) (crimson-bike-lod1-mg (meters 40)) (crimson-bike-lod2-mg (meters 999999))) + :bounds (static-spherem 0 0 0 3.4) + :shadow crimson-bike-shadow-mg + ) + +(define *bike-explosion-info* + (new 'static 'vehicle-explosion-info + :joints (new 'static 'boxed-array :type joint-exploder-static-joint-params + (new 'static 'joint-exploder-static-joint-params :joint-index 3 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 4 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 5 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 6 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 7 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 8 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 9 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 10 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 11 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 12 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 13 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 14 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 15 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 16 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 17 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 18 :parent-joint-index -1) + ) + :collide-spec #x1 + :art-level 'ctywide + :skel #f + :skel-name "skel-vehicle-explosion" + :anim 2 + ) + ) + +(define *bikea-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 2.0 + :inv-mass 0.5 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :z 2457.6 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 3) (meters 4) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*bikea-constants* + :flags #x70 + :object-type #xb + :guard-type #x7 + :max-engine-thrust (meters 50) + :inv-max-engine-thrust 0.0000048828124 + :engine-response-rate 60.0 + :engine-intake-factor 1.5 + :brake-factor 3.5 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.3 + :air-drag-factor 1.0 + :steering-thruster-factor 5.0 + :steering-thruster-max-gain 4.0 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.5 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.75 + :pitch-control-factor 1.0 + :roll-control-factor 1.0 + :jump-thrust-factor 0.625 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 4) + :turning-accel (meters 25) + :toughness-factor 1.0 + :damage-factor 4.0 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 5461.3335 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 2 + :section-count 2 + :grab-rail-count 2 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 2 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x 2048.0 :z 4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -2048.0 :z 4096.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info :position (new 'static 'vector :w (the-as float #x10000))) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 2048.0 :z -4096.0 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 409.6 :z 4710.4 :w 1.0) + (new 'static 'vector :x -2457.6 :y 409.6 :z 4710.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x10 #x8 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x20 #x4 #x0) + :damage-seg-count 2 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-offset -0.25 + :engine-pitch-mod-amp 0.05 + :engine-sound-select 1 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "bike-scrape-stn") + :glance-sound (static-sound-name "bike-glance-stn") + :impact-sound (static-sound-name "bike-impact-stn") + :extra-sound (static-sound-name "bike-by-1") + :explosion-part #xa1 + :headlight-count 1 + :taillight-count 1 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :z -3276.8 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :y 204.8 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :y 204.8 :z -3276.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1638.4 :y -2048.0 :z 7372.8 :w 1.0) + (new 'static 'vector :x -1638.4 :y -2048.0 :z 7372.8 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 (new 'static 'vector :w 1.0) (new 'static 'vector :w 1.0)) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :y -819.2 :z 10240.0 :w 1.0) + (new 'static 'vector) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 (new 'static 'vector :y 1433.6 :z -10240.0 :w 1.0) (new 'static 'vector)) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z 7372.8003 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z -2457.6 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10240.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5324.8 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10649.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :brake-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :color-option-count 3 + :color-option-array (new 'static 'inline-array vector 3 + (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 0.7 :w 1.0) + ) + ) + ) + +(define *bikeb-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 2.0 + :inv-mass 0.5 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :z 2457.6 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 3) (meters 4) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*bikeb-constants* + :flags #x70 + :object-type #xc + :guard-type #x7 + :max-engine-thrust (meters 50) + :inv-max-engine-thrust 0.0000048828124 + :engine-response-rate 60.0 + :engine-intake-factor 1.5 + :brake-factor 3.5 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.3 + :air-drag-factor 1.0 + :steering-thruster-factor 5.0 + :steering-thruster-max-gain 4.0 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.5 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.75 + :pitch-control-factor 1.0 + :roll-control-factor 1.0 + :jump-thrust-factor 0.625 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 4) + :turning-accel (meters 25) + :toughness-factor 1.0 + :damage-factor 4.0 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 5461.3335 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 2 + :section-count 2 + :grab-rail-count 2 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 2 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x 2048.0 :z 4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -2048.0 :z 4096.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 757.76 :z 1175.552 :w (the-as float #x10000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 2048.0 :z -4096.0 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 409.6 :z 4710.4 :w 1.0) + (new 'static 'vector :x -2457.6 :y 409.6 :z 4710.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x20 #x8 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x40 #x10 #x4) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-offset -0.25 + :engine-pitch-mod-amp 0.05 + :engine-sound-select 1 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "bike-scrape-stn") + :glance-sound (static-sound-name "bike-glance-stn") + :impact-sound (static-sound-name "bike-impact-stn") + :extra-sound (static-sound-name "bike-by-1") + :explosion-part #xa1 + :headlight-count 1 + :taillight-count 1 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :z -3276.8 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :y 204.8 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :y 204.8 :z -3276.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1638.4 :y -2048.0 :z 7372.8 :w 1.0) + (new 'static 'vector :x -1638.4 :y -2048.0 :z 7372.8 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 (new 'static 'vector :w 1.0) (new 'static 'vector :w 1.0)) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :z 11059.2 :w 1.0) + (new 'static 'vector) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 (new 'static 'vector :y 1433.6 :z -8192.0 :w 1.0) (new 'static 'vector)) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 7372.8003 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -2457.6 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10240.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5324.8 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10649.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :brake-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :color-option-count 3 + :color-option-array (new 'static 'inline-array vector 3 + (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 0.7 :w 1.0) + ) + ) + ) + +(define *bikec-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 2.0 + :inv-mass 0.5 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :z 2457.6 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 3) (meters 4) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*bikec-constants* + :flags #x70 + :object-type #xd + :guard-type #x7 + :max-engine-thrust (meters 50) + :inv-max-engine-thrust 0.0000048828124 + :engine-response-rate 60.0 + :engine-intake-factor 1.5 + :brake-factor 3.5 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.3 + :air-drag-factor 1.0 + :steering-thruster-factor 5.0 + :steering-thruster-max-gain 4.0 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.5 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.75 + :pitch-control-factor 1.0 + :roll-control-factor 1.0 + :jump-thrust-factor 0.625 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 4) + :turning-accel (meters 25) + :toughness-factor 1.0 + :damage-factor 4.0 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 3640.889 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 2 + :section-count 2 + :grab-rail-count 2 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 2 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x 2048.0 :z 8192.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -2048.0 :z 8192.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 802.816 :z 1318.912 :w (the-as float #x10000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 2048.0 :z -4096.0 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 409.6 :z 4710.4 :w 1.0) + (new 'static 'vector :x -2457.6 :y 409.6 :z 4710.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x20 #x8 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x40 #x10 #x4) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-offset -0.25 + :engine-pitch-mod-amp 0.05 + :engine-sound-select 1 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "bike-scrape-stn") + :glance-sound (static-sound-name "bike-glance-stn") + :impact-sound (static-sound-name "bike-impact-stn") + :extra-sound (static-sound-name "bike-by-1") + :explosion-part #xa1 + :headlight-count 1 + :taillight-count 1 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :z -3276.8 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :y 204.8 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :y 204.8 :z -3276.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1638.4 :y -2048.0 :z 7372.8 :w 1.0) + (new 'static 'vector :x -1638.4 :y -2048.0 :z 7372.8 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 (new 'static 'vector :w 1.0) (new 'static 'vector :w 1.0)) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :y -614.4 :z 13721.6 :w 1.0) + (new 'static 'vector) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 (new 'static 'vector :y 614.4 :z -7168.0 :w 1.0) (new 'static 'vector)) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 7372.8003 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -2457.6 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10240.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5324.8 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10649.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :brake-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :color-option-count 3 + :color-option-array (new 'static 'inline-array vector 3 + (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 0.7 :w 1.0) + ) + ) + ) + +(define *guard-bike-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 2.0 + :inv-mass 0.5 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :z 2457.6 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 3) (meters 4) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*guard-bike-constants* + :flags #x54 + :object-type #x12 + :guard-type #x4 + :max-engine-thrust (meters 50) + :inv-max-engine-thrust 0.0000048828124 + :engine-response-rate 60.0 + :engine-intake-factor 1.5 + :brake-factor 3.5 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.3 + :air-drag-factor 1.0 + :steering-thruster-factor 5.0 + :steering-thruster-max-gain 4.0 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.5 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000034877234 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.75 + :pitch-control-factor 1.0 + :roll-control-factor 1.0 + :jump-thrust-factor 0.625 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 4) + :turning-accel (meters 25) + :toughness-factor 1.0 + :damage-factor 4.0 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 5461.3335 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 2 + :section-count 2 + :grab-rail-count 2 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 2 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x 2048.0 :z 4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -2048.0 :z 4096.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info :position (new 'static 'vector :w (the-as float #x10000))) + (new 'static 'vehicle-seat-info :position (new 'static 'vector :z -4096.0 :w (the-as float #x40000))) + (new 'static 'vehicle-seat-info) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 409.6 :z 4710.4 :w 1.0) + (new 'static 'vector :x -2457.6 :y 409.6 :z 4710.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x20 #x8 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x40 #x10 #x4) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-offset -0.25 + :engine-pitch-mod-amp 0.05 + :engine-sound-select 1 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "bike-scrape-stn") + :glance-sound (static-sound-name "bike-glance-stn") + :impact-sound (static-sound-name "bike-impact-stn") + :extra-sound (static-sound-name "bike-by-1") + :explosion-part #xa1 + :headlight-count 1 + :taillight-count 1 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :z -11878.4 :w 1.0) + (new 'static 'vector :x -1024.0 :z -11878.4 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :y 204.8 :z -3276.8 :w 1.0) + (new 'static 'vector :x -2048.0 :y 204.8 :z -3276.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 + (new 'static 'vector :x 0.7 :z -0.7 :w 1.0) + (new 'static 'vector :x -0.7 :z -0.7 :w 1.0) + ) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :y 204.8 :z -4505.6 :w 1.0) + (new 'static 'vector :x -2048.0 :y 204.8 :z -4505.6 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :y 819.2 :z 12288.0 :w 1.0) + (new 'static 'vector) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 (new 'static 'vector :y 2867.2 :z -9420.8 :w 1.0) (new 'static 'vector)) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 7372.8003 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -2457.6 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10240.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5324.8 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10649.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :brake-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :color-option-count 1 + :color-option-array (new 'static 'inline-array vector 1 (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0)) + ) + ) + +(set! (-> *bikea-constants* explosion) *bike-explosion-info*) + +(set! (-> *bikeb-constants* explosion) *bike-explosion-info*) + +(set! (-> *bikec-constants* explosion) *bike-explosion-info*) + +(set! (-> *guard-bike-constants* explosion) *bike-explosion-info*) + +(deftype bike-base (vehicle) + () + :heap-base #x2f0 + :method-count-assert 144 + :size-assert #x370 + :flag-assert #x9002f00370 + ) + + +(defmethod do-engine-sounds bike-base ((obj bike-base)) + ((the-as (function object none) (find-parent-method bike-base 36)) obj) + (when (logtest? (-> obj flags) (rigid-body-object-flag player-driving)) + (if (zero? (-> obj roll-sound-id)) + (set! (-> obj roll-sound-id) (new-sound-id)) + ) + (let* ((f0-4 + (* 4.0 + (-> obj force-scale) + (-> obj sputter-sound-envelope) + (-> obj info-override inv-max-engine-thrust) + (+ (-> obj roll-thrust 0) (-> obj roll-thrust 1)) + ) + ) + (f1-6 (* 0.32 f0-4)) + (f0-5 0.5) + ) + (sound-play-by-name + (static-sound-name "bike-thrust") + (-> obj roll-sound-id) + (the int (* 1024.0 f1-6)) + (the int (* 1524.0 f0-5)) + 0 + (sound-group sfx) + #t + ) + ) + ) + 0 + (none) + ) + +(defmethod draw-thrusters bike-base ((obj bike-base)) + ((the-as (function object none) (find-parent-method bike-base 85)) obj) + (when (logtest? (-> obj rbody state flags) (rigid-body-flag enable-physics)) + (let ((s5-0 (new 'stack-no-clear 'inline-array 'matrix 3))) + (let* ((v1-4 (the-as object (-> s5-0 0 vector 2))) + (a3-0 (-> obj node-list data 0 bone transform)) + (a0-5 (-> a3-0 quad 0)) + (a1-1 (-> a3-0 quad 1)) + (a2-0 (-> a3-0 quad 2)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> (the-as vector v1-4) quad) a0-5) + (set! (-> (the-as (pointer uint128) v1-4) 1) a1-1) + (set! (-> (the-as (pointer uint128) v1-4) 2) a2-0) + (set! (-> (the-as (pointer uint128) v1-4) 3) a3-1) + ) + (set-vector! (-> s5-0 0 vector 1) 0.0 -1.0 0.0 1.0) + (vector-rotate*! (-> s5-0 0 vector 1) (-> s5-0 0 vector 1) (the-as matrix (-> s5-0 0 vector 2))) + (let ((s4-0 (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :y -1228.8 :z 2457.6 :w 1.0) + (new 'static 'vector :x -2048.0 :y -1228.8 :z 2457.6 :w 1.0) + ) + ) + (s3-0 (new 'static 'inline-array vector 2 + (new 'static 'vector :x 0.707 :y -0.707 :w 1.0) + (new 'static 'vector :x -0.707 :y -0.707 :w 1.0) + ) + ) + ) + (dotimes (s2-0 2) + (when (< 0.0 (-> obj roll-thrust s2-0)) + (vector-rotate*! (-> s5-0 0 vector 1) (-> s3-0 s2-0) (the-as matrix (-> s5-0 0 vector 2))) + (vector-matrix*! (the-as vector (-> s5-0 0)) (-> s4-0 s2-0) (the-as matrix (-> s5-0 0 vector 2))) + (let* ((a0-11 obj) + (t9-5 (method-of-object a0-11 draw-thruster)) + (a1-5 (-> s5-0 0)) + (a2-4 (-> s5-0 0 vector 1)) + (a3-2 1638.4) + (f0-5 12288.0) + (f1-1 (-> obj info-override extra gravity)) + ) + (t9-5 + a0-11 + (the-as vector a1-5) + a2-4 + a3-2 + (* f0-5 (/ 1.0 f1-1) (-> obj info-override info inv-mass) (-> obj force-scale) (-> obj roll-thrust s2-0)) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(deftype bikea (bike-base) + ((fin-fl joint-mod-rotate-local :offset-assert 880) + (fin-fr joint-mod-rotate-local :offset-assert 884) + (fin-rl joint-mod-rotate-local :offset-assert 888) + (fin-rr joint-mod-rotate-local :offset-assert 892) + (rudder joint-mod-rotate-local :offset-assert 896) + (brake-l joint-mod-rotate-local :offset-assert 900) + (brake-r joint-mod-rotate-local :offset-assert 904) + ) + :heap-base #x310 + :method-count-assert 144 + :size-assert #x38c + :flag-assert #x900310038c + ) + + +(defmethod relocate bikea ((obj bikea) (arg0 int)) + (if (nonzero? (-> obj fin-fl)) + (&+! (-> obj fin-fl) arg0) + ) + (if (nonzero? (-> obj fin-fr)) + (&+! (-> obj fin-fr) arg0) + ) + (if (nonzero? (-> obj fin-rl)) + (&+! (-> obj fin-rl) arg0) + ) + (if (nonzero? (-> obj fin-rr)) + (&+! (-> obj fin-rr) arg0) + ) + (if (nonzero? (-> obj rudder)) + (&+! (-> obj rudder) arg0) + ) + (if (nonzero? (-> obj brake-l)) + (&+! (-> obj brake-l) arg0) + ) + (if (nonzero? (-> obj brake-r)) + (&+! (-> obj brake-r) arg0) + ) + ((the-as (function object int bikea) (find-parent-method bikea 7)) obj arg0) + ) + +(defmethod allocate-and-init-cshape bikea ((obj bikea)) + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-default) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate vehicle)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 5) 0))) + (set! (-> s5-0 total-prims) (the-as uint 6)) + (set! (-> s4-0 prim-core action) (collide-action solid)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 11264.0) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-11 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-11 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-11 transform-index) 0) + (set-vector! (-> v1-11 local-sphere) 0.0 -819.2 4505.6 3686.4) + (set! (-> v1-11 nav-radius) 6144.0) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-13 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-13 transform-index) 0) + (set-vector! (-> v1-13 local-sphere) 0.0 0.0 -3686.4 4096.0) + (set! (-> v1-13 nav-radius) 6144.0) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 96)))) + (set! (-> v1-15 prim-core action) (collide-action solid)) + (set! (-> v1-15 transform-index) 0) + (set-vector! (-> v1-15 local-sphere) 204.8 3276.8 1228.8 3276.8) + ) + (let ((v1-17 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-17 prim-core action) (collide-action solid)) + (set! (-> v1-17 transform-index) 0) + (set-vector! (-> v1-17 local-sphere) 0.0 -819.2 9011.2 1638.4) + ) + (let ((v1-19 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-19 prim-core action) (collide-action solid)) + (set! (-> v1-19 transform-index) 0) + (set-vector! (-> v1-19 local-sphere) 0.0 1228.8 -8601.6 2048.0) + ) + (set! (-> s5-0 nav-radius) 16384.0) + (let ((v1-21 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-21 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-21 prim-core collide-with)) + ) + (set! (-> s5-0 nav-flags) (nav-flags has-child-spheres)) + (set! (-> obj root-override-2) s5-0) + ) + 0 + (none) + ) + +(defmethod update-joint-mods bikea ((obj bikea)) + (let ((f30-0 (* 5461.3335 (-> obj controls steering))) + (f26-0 (* -5461.3335 (-> obj controls lean-z))) + (f28-0 (* -13653.333 (-> obj controls brake))) + (s5-0 (new 'static 'vector :x 1.0 :w 1.0)) + ) + (quaternion-vector-angle! (-> obj fin-rl rotation) s5-0 (+ f26-0 (* 0.2 f30-0))) + (quaternion-vector-angle! (-> obj fin-rr rotation) s5-0 (+ (- f26-0) (* 0.2 f30-0))) + (quaternion-vector-angle! (-> obj fin-fl rotation) s5-0 (- (* -0.2 f26-0) f30-0)) + (quaternion-vector-angle! (-> obj fin-fr rotation) s5-0 (- (* 0.2 f26-0) f30-0)) + (quaternion-vector-angle! (-> obj rudder rotation) s5-0 f30-0) + (quaternion-vector-angle! (-> obj brake-l rotation) s5-0 f28-0) + (quaternion-vector-angle! (-> obj brake-r rotation) s5-0 f28-0) + ) + 0 + (none) + ) + +(defmethod init-skel-and-rigid-body bikea ((obj bikea)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-bikea" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *bikea-constants*) + (set! (-> obj fin-fl) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj fin-fr) (new 'process 'joint-mod-rotate-local obj 7 #t)) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj rudder) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj brake-l) (new 'process 'joint-mod-rotate-local obj 9 #t)) + (set! (-> obj brake-r) (new 'process 'joint-mod-rotate-local obj 10 #t)) + 0 + (none) + ) + +(deftype bikeb (bike-base) + ((fin-rl joint-mod-rotate-local :offset-assert 880) + (fin-rr joint-mod-rotate-local :offset-assert 884) + (rudder joint-mod-rotate-local :offset-assert 888) + (rudder-f joint-mod-rotate-local :offset-assert 892) + (brake-l joint-mod-rotate-local :offset-assert 896) + (brake-r joint-mod-rotate-local :offset-assert 900) + (flap-l joint-mod-rotate-local :offset-assert 904) + (flap-r joint-mod-rotate-local :offset-assert 908) + ) + :heap-base #x310 + :method-count-assert 144 + :size-assert #x390 + :flag-assert #x9003100390 + ) + + +(defmethod relocate bikeb ((obj bikeb) (arg0 int)) + (if (nonzero? (-> obj fin-rl)) + (&+! (-> obj fin-rl) arg0) + ) + (if (nonzero? (-> obj fin-rr)) + (&+! (-> obj fin-rr) arg0) + ) + (if (nonzero? (-> obj rudder)) + (&+! (-> obj rudder) arg0) + ) + (if (nonzero? (-> obj rudder-f)) + (&+! (-> obj rudder-f) arg0) + ) + (if (nonzero? (-> obj brake-l)) + (&+! (-> obj brake-l) arg0) + ) + (if (nonzero? (-> obj brake-r)) + (&+! (-> obj brake-r) arg0) + ) + (if (nonzero? (-> obj flap-l)) + (&+! (-> obj flap-l) arg0) + ) + (if (nonzero? (-> obj flap-r)) + (&+! (-> obj flap-r) arg0) + ) + ((the-as (function object int bikeb) (find-parent-method bikeb 7)) obj arg0) + ) + +(defmethod allocate-and-init-cshape bikeb ((obj bikeb)) + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-default) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate vehicle)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 5) 0))) + (set! (-> s5-0 total-prims) (the-as uint 6)) + (set! (-> s4-0 prim-core action) (collide-action solid)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 11264.0) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-11 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-11 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-11 transform-index) 0) + (set-vector! (-> v1-11 local-sphere) 0.0 -409.6 4505.6 4300.8) + (set! (-> v1-11 nav-radius) 6144.0) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-13 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-13 transform-index) 0) + (set-vector! (-> v1-13 local-sphere) 0.0 0.0 -3686.4 4096.0) + (set! (-> v1-13 nav-radius) 6144.0) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 96)))) + (set! (-> v1-15 prim-core action) (collide-action solid)) + (set! (-> v1-15 transform-index) 0) + (set-vector! (-> v1-15 local-sphere) 204.8 3276.8 1228.8 3276.8) + ) + (let ((v1-17 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-17 prim-core action) (collide-action solid)) + (set! (-> v1-17 transform-index) 0) + (set-vector! (-> v1-17 local-sphere) 0.0 -819.2 9011.2 1638.4) + ) + (let ((v1-19 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-19 prim-core action) (collide-action solid)) + (set! (-> v1-19 transform-index) 0) + (set-vector! (-> v1-19 local-sphere) 0.0 1228.8 -8601.6 2048.0) + ) + (set! (-> s5-0 nav-radius) 16384.0) + (let ((v1-21 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-21 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-21 prim-core collide-with)) + ) + (set! (-> s5-0 nav-flags) (nav-flags has-child-spheres)) + (set! (-> obj root-override-2) s5-0) + ) + 0 + (none) + ) + +(defmethod update-joint-mods bikeb ((obj bikeb)) + (let ((f30-0 (* 5461.3335 (-> obj controls steering))) + (f26-0 (* -5461.3335 (-> obj controls lean-z))) + (f28-0 (* 13653.333 (-> obj controls brake))) + (s5-0 (new 'static 'vector :x 1.0 :w 1.0)) + ) + (quaternion-vector-angle! (-> obj fin-rl rotation) s5-0 (+ f26-0 (* 0.2 f30-0))) + (quaternion-vector-angle! (-> obj fin-rr rotation) s5-0 (+ (- f26-0) (* 0.2 f30-0))) + (quaternion-vector-angle! (-> obj rudder rotation) s5-0 f30-0) + (quaternion-vector-angle! (-> obj rudder-f rotation) s5-0 (- f30-0)) + (quaternion-vector-angle! (-> obj brake-l rotation) s5-0 (- f28-0)) + (quaternion-vector-angle! (-> obj brake-r rotation) s5-0 f28-0) + (quaternion-vector-angle! (-> obj flap-l rotation) s5-0 f28-0) + (quaternion-vector-angle! (-> obj flap-r rotation) s5-0 (- f28-0)) + ) + 0 + (none) + ) + +(defmethod init-skel-and-rigid-body bikeb ((obj bikeb)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-bikeb" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *bikeb-constants*) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 10 #t)) + (set! (-> obj rudder) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj rudder-f) (new 'process 'joint-mod-rotate-local obj 7 #t)) + (set! (-> obj brake-l) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj brake-r) (new 'process 'joint-mod-rotate-local obj 9 #t)) + (set! (-> obj flap-l) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj flap-r) (new 'process 'joint-mod-rotate-local obj 11 #t)) + 0 + (none) + ) + +(deftype bikec (bike-base) + ((fin-fl joint-mod-rotate-local :offset-assert 880) + (fin-fr joint-mod-rotate-local :offset-assert 884) + (fin-rl joint-mod-rotate-local :offset-assert 888) + (fin-rr joint-mod-rotate-local :offset-assert 892) + (fin2-fl joint-mod-rotate-local :offset-assert 896) + (fin2-fr joint-mod-rotate-local :offset-assert 900) + (rudder joint-mod-rotate-local :offset-assert 904) + (brake-l joint-mod-rotate-local :offset-assert 908) + (brake-r joint-mod-rotate-local :offset-assert 912) + (spoiler-l joint-mod-rotate-local :offset-assert 916) + (spoiler-r joint-mod-rotate-local :offset-assert 920) + ) + :heap-base #x320 + :method-count-assert 144 + :size-assert #x39c + :flag-assert #x900320039c + ) + + +(defmethod relocate bikec ((obj bikec) (arg0 int)) + (if (nonzero? (-> obj fin-fl)) + (&+! (-> obj fin-fl) arg0) + ) + (if (nonzero? (-> obj fin-fr)) + (&+! (-> obj fin-fr) arg0) + ) + (if (nonzero? (-> obj fin-rl)) + (&+! (-> obj fin-rl) arg0) + ) + (if (nonzero? (-> obj fin-rr)) + (&+! (-> obj fin-rr) arg0) + ) + (if (nonzero? (-> obj fin2-fl)) + (&+! (-> obj fin2-fl) arg0) + ) + (if (nonzero? (-> obj fin2-fr)) + (&+! (-> obj fin2-fr) arg0) + ) + (if (nonzero? (-> obj rudder)) + (&+! (-> obj rudder) arg0) + ) + (if (nonzero? (-> obj brake-l)) + (&+! (-> obj brake-l) arg0) + ) + (if (nonzero? (-> obj brake-r)) + (&+! (-> obj brake-r) arg0) + ) + (if (nonzero? (-> obj spoiler-l)) + (&+! (-> obj spoiler-l) arg0) + ) + (if (nonzero? (-> obj spoiler-r)) + (&+! (-> obj spoiler-r) arg0) + ) + ((the-as (function object int bikec) (find-parent-method bikec 7)) obj arg0) + ) + +(defmethod allocate-and-init-cshape bikec ((obj bikec)) + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-default) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate vehicle)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 5) 0))) + (set! (-> s5-0 total-prims) (the-as uint 6)) + (set! (-> s4-0 prim-core action) (collide-action solid)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 13312.0) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-11 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-11 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-11 transform-index) 0) + (set-vector! (-> v1-11 local-sphere) 0.0 0.0 4505.6 4300.8) + (set! (-> v1-11 nav-radius) 7577.6) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-13 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-13 transform-index) 0) + (set-vector! (-> v1-13 local-sphere) 0.0 0.0 -3686.4 4096.0) + (set! (-> v1-13 nav-radius) 6144.0) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 96)))) + (set! (-> v1-15 prim-core action) (collide-action solid)) + (set! (-> v1-15 transform-index) 0) + (set-vector! (-> v1-15 local-sphere) 204.8 3276.8 1228.8 3276.8) + ) + (let ((v1-17 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-17 prim-core action) (collide-action solid)) + (set! (-> v1-17 transform-index) 0) + (set-vector! (-> v1-17 local-sphere) 0.0 0.0 9011.2 3686.4) + ) + (let ((v1-19 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-19 prim-core action) (collide-action solid)) + (set! (-> v1-19 transform-index) 0) + (set-vector! (-> v1-19 local-sphere) 0.0 1228.8 -8601.6 2048.0) + ) + (set! (-> s5-0 nav-radius) 16384.0) + (let ((v1-21 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-21 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-21 prim-core collide-with)) + ) + (set! (-> s5-0 nav-flags) (nav-flags has-child-spheres)) + (set! (-> obj root-override-2) s5-0) + ) + 0 + (none) + ) + +(defmethod update-joint-mods bikec ((obj bikec)) + (let ((f30-0 (* 5461.3335 (-> obj controls steering))) + (f26-0 (* -5461.3335 (-> obj controls lean-z))) + (f28-0 (* 13653.333 (-> obj controls brake))) + (s5-0 (new 'static 'vector :x 1.0 :w 1.0)) + ) + (quaternion-vector-angle! (-> obj fin-fl rotation) s5-0 (- f26-0)) + (quaternion-vector-angle! (-> obj fin-fr rotation) s5-0 f26-0) + (quaternion-vector-angle! (-> obj fin2-fl rotation) s5-0 (- f26-0)) + (quaternion-vector-angle! (-> obj fin2-fr rotation) s5-0 f26-0) + (quaternion-vector-angle! (-> obj fin-rl rotation) s5-0 (+ f26-0 (* 0.2 f30-0))) + (quaternion-vector-angle! (-> obj fin-rr rotation) s5-0 (+ (- f26-0) (* 0.2 f30-0))) + (quaternion-vector-angle! (-> obj rudder rotation) s5-0 f30-0) + (quaternion-vector-angle! (-> obj brake-l rotation) s5-0 (- f28-0)) + (quaternion-vector-angle! (-> obj brake-r rotation) s5-0 f28-0) + (quaternion-vector-angle! (-> obj spoiler-l rotation) s5-0 f28-0) + (quaternion-vector-angle! (-> obj spoiler-r rotation) s5-0 (- f28-0)) + ) + 0 + (none) + ) + +(defmethod init-skel-and-rigid-body bikec ((obj bikec)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-bikec" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *bikec-constants*) + (set! (-> obj fin-fl) (new 'process 'joint-mod-rotate-local obj 7 #t)) + (set! (-> obj fin-fr) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 9 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 10 #t)) + (set! (-> obj fin2-fl) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj fin2-fr) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj rudder) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj brake-l) (new 'process 'joint-mod-rotate-local obj 11 #t)) + (set! (-> obj brake-r) (new 'process 'joint-mod-rotate-local obj 12 #t)) + (set! (-> obj spoiler-l) (new 'process 'joint-mod-rotate-local obj 13 #t)) + (set! (-> obj spoiler-r) (new 'process 'joint-mod-rotate-local obj 14 #t)) + 0 + (none) + ) + +(define *guard-bike-turret-control-info* (new 'static 'turret-control-info + :joint-index 4 + :barrel-count 1 + :shot-speed 819200.0 + :attack-range 286720.0 + :rot-min (new 'static 'array float 2 -16384.0 -21845.334) + :rot-max (new 'static 'array float 2 0.0 21845.334) + :local-pos (new 'static 'vector :y -1433.6 :z 4096.0 :w 1.0) + :local-dir (new 'static 'vector :z 1.0 :w 1.0) + :barrel-array (new 'static 'inline-array turret-barrel-info 4 + (new 'static 'turret-barrel-info + :local-pos (new 'static 'vector :y -1433.6 :z 4096.0 :w 1.0) + :local-dir (new 'static 'vector :z 1.0 :w 1.0) + ) + (new 'static 'turret-barrel-info) + (new 'static 'turret-barrel-info) + (new 'static 'turret-barrel-info) + ) + ) + ) + +(deftype guard-bike (vehicle-guard) + ((turret-jm joint-mod-rotate-local :offset-assert 1076) + ) + :heap-base #x3c0 + :method-count-assert 159 + :size-assert #x438 + :flag-assert #x9f03c00438 + ) + + +(defmethod relocate guard-bike ((obj guard-bike) (arg0 int)) + (if (nonzero? (-> obj turret-jm)) + (&+! (-> obj turret-jm) arg0) + ) + ((the-as (function object int guard-bike) (find-parent-method guard-bike 7)) obj arg0) + ) + +(defmethod start-jump guard-bike ((obj guard-bike)) + (when (not (logtest? (rigid-body-object-flag jump-sound) (-> obj flags))) + (set! (-> obj flags) (logior (rigid-body-object-flag jump-sound) (-> obj flags))) + (sound-play "bike-hop") + ) + (set! (-> obj flags) (logior (rigid-body-object-flag jump) (-> obj flags))) + 0 + (none) + ) + +(defmethod allocate-and-init-cshape guard-bike ((obj guard-bike)) + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-default) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate vehicle)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 5) 0))) + (set! (-> s5-0 total-prims) (the-as uint 6)) + (set! (-> s4-0 prim-core action) (collide-action solid)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 13312.0) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-11 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-11 prim-core action) (collide-action solid)) + (set! (-> v1-11 transform-index) 0) + (set-vector! (-> v1-11 local-sphere) 0.0 0.0 4505.6 4300.8) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-13 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-13 transform-index) 0) + (set-vector! (-> v1-13 local-sphere) 0.0 0.0 -3686.4 4096.0) + (set! (-> v1-13 nav-radius) 7168.0) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 96)))) + (set! (-> v1-15 prim-core action) (collide-action solid)) + (set! (-> v1-15 transform-index) 0) + (set-vector! (-> v1-15 local-sphere) 204.8 3276.8 1228.8 3276.8) + ) + (let ((v1-17 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-17 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-17 transform-index) 0) + (set-vector! (-> v1-17 local-sphere) 0.0 0.0 9011.2 3686.4) + (set! (-> v1-17 nav-radius) 7168.0) + ) + (let ((v1-19 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-19 prim-core action) (collide-action solid)) + (set! (-> v1-19 transform-index) 0) + (set-vector! (-> v1-19 local-sphere) 0.0 -1638.4 -8192.0 3686.4) + ) + (set! (-> s5-0 nav-radius) 16384.0) + (let ((v1-21 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-21 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-21 prim-core collide-with)) + ) + (set! (-> s5-0 nav-flags) (nav-flags has-child-spheres)) + (set! (-> obj root-override-2) s5-0) + ) + 0 + (none) + ) + +(defmethod update-joint-mods guard-bike ((obj guard-bike)) + (update-joint-mod (-> obj turret) (-> obj turret-jm)) + 0 + (none) + ) + +(defmethod init-skel-and-rigid-body guard-bike ((obj guard-bike)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-guard-bike" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *guard-bike-constants*) + (set-info (-> obj turret) *guard-bike-turret-control-info*) + (set! (-> obj turret-jm) (new 'process 'joint-mod-rotate-local obj (-> obj turret info joint-index) #t)) + 0 + (none) + ) diff --git a/goal_src/jak2/levels/city/common/car.gc b/goal_src/jak2/levels/city/common/car.gc index 2bee9eb05f..49ac8168e4 100644 --- a/goal_src/jak2/levels/city/common/car.gc +++ b/goal_src/jak2/levels/city/common/car.gc @@ -7,3 +7,1662 @@ ;; DECOMP BEGINS +(defskelgroup skel-cara cara cara-lod0-jg cara-idle-ja + ((cara-lod0-mg (meters 20)) (cara-lod1-mg (meters 40)) (cara-lod2-mg (meters 999999))) + :bounds (static-spherem 0 0 0 5.2) + :shadow cara-shadow-mg + ) + +(defskelgroup skel-carb carb carb-lod0-jg carb-idle-ja + ((carb-lod0-mg (meters 20)) (carb-lod1-mg (meters 40)) (carb-lod2-mg (meters 999999))) + :bounds (static-spherem 0 0 0 5) + :shadow carb-shadow-mg + ) + +(defskelgroup skel-carc carc carc-lod0-jg carc-idle-ja + ((carc-lod0-mg (meters 20)) (carc-lod1-mg (meters 40)) (carc-lod2-mg (meters 999999))) + :bounds (static-spherem 0 0 0 5.3) + :shadow carc-shadow-mg + ) + +(defskelgroup skel-hellcat hellcat hellcat-lod0-jg hellcat-idle-ja + ((hellcat-lod0-mg (meters 20)) (hellcat-lod1-mg (meters 40)) (hellcat-lod2-mg (meters 999999))) + :bounds (static-spherem 0 0 0 6.8) + :shadow hellcat-shadow-mg + :origin-joint-index 3 + ) + +(define *car-explosion-info* + (new 'static 'vehicle-explosion-info + :joints (new 'static 'boxed-array :type joint-exploder-static-joint-params + (new 'static 'joint-exploder-static-joint-params :joint-index 3 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 4 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 5 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 6 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 7 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 8 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 9 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 10 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 11 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 12 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 13 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 14 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 15 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 16 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 17 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 18 :parent-joint-index -1) + ) + :collide-spec #x1 + :art-level 'ctywide + :skel #f + :skel-name "skel-vehicle-explosion" + :anim 2 + ) + ) + +(define *cara-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 8.0 + :inv-mass 0.125 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 4) (meters 3) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*cara-constants* + :flags #x68 + :object-type #xe + :guard-type #x7 + :max-engine-thrust (meters 39) + :inv-max-engine-thrust 0.000006260016 + :engine-response-rate 20.0 + :engine-intake-factor 1.0 + :brake-factor 2.25 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 4.5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.4 + :air-drag-factor 1.0 + :steering-thruster-factor 3.0 + :steering-thruster-max-gain 3.5 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.6 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.7 + :pitch-control-factor 0.5 + :roll-control-factor 1.0 + :jump-thrust-factor 0.5 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 3) + :turning-accel (meters 20) + :toughness-factor 1.0 + :damage-factor 2.5 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 5461.3335 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 3 + :section-count 4 + :rider-stance #x1 + :grab-rail-count #x6 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 6 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 4505.6 :y -2662.4 :z 15360.0 :w 1.0) + (new 'static 'vector :x -4505.6 :y -2662.4 :z 15360.0 :w 1.0) + ) + :normal (new 'static 'vector :z 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 7372.8 :y -819.2 :z -4096.0 :w 1.0) + (new 'static 'vector :x 7372.8 :y -819.2 :z 4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -7372.8 :y -819.2 :z 4096.0 :w 1.0) + (new 'static 'vector :x -7372.8 :y -819.2 :z -4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -3686.4 :y -409.6 :z -14950.4 :w 1.0) + (new 'static 'vector :x 3686.4 :y -409.6 :z -14950.4 :w 1.0) + ) + :normal (new 'static 'vector :z -1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3837.952 :y -409.6 :z -14950.4 :w 1.0) + (new 'static 'vector :x 6041.6 :y -614.4 :z -9011.2 :w 1.0) + ) + :normal (new 'static 'vector :x 0.707 :z -0.707 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -6041.6 :y -614.4 :z -9011.2 :w 1.0) + (new 'static 'vector :x -3837.952 :y -409.6 :z -14950.4 :w 1.0) + ) + :normal (new 'static 'vector :x -0.707 :z -0.707 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :x 4079.616 :y 819.2 :z -311.296 :w (the-as float #x30000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :x -4079.616 :y 819.2 :z -311.296 :w (the-as float #x30000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 3751.936 :z -10563.584 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 614.4 :y 614.4 :z 1433.6 :w 1.0) + (new 'static 'vector :x 614.4 :y 614.4 :z -1433.6 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x200 #x20 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x400 #x40 #x4) + :damage-seg-count 3 + ) + :section-car-front-right (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x800 #x80 #x8) + :damage-seg-count 3 + ) + :section-car-rear-right (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x1000 #x100 #x10) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.09 + :engine-pitch-mod-amp 0.01 + :engine-sound-select 5 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "car-scrape-stn") + :glance-sound (static-sound-name "car-glance-stn") + :impact-sound (static-sound-name "car-impact-stn") + :extra-sound (static-sound-name "car-by-5") + :explosion-part #xa1 + :headlight-count 2 + :taillight-count 2 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3072.0 :z -14336.0 :w 1.0) + (new 'static 'vector :x -3072.0 :z -14336.0 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 6963.2 :y -1024.0 :z -7372.8 :w 1.0) + (new 'static 'vector :x -6963.2 :y -1024.0 :z -7372.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3072.0 :z -13926.4 :w 1.0) + (new 'static 'vector :x -3072.0 :z -13926.4 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 + (new 'static 'vector :x 12288.0 :w 1.0) + (new 'static 'vector :x -12288.0 :w 1.0) + ) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :x 4915.2 :z 15564.8 :w 1.0) + (new 'static 'vector :x -4915.2 :z 15564.8 :w 1.0) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3276.8 :y 3276.8 :z -14131.2 :w 1.0) + (new 'static 'vector :x -3276.8 :y 3276.8 :z -14131.2 :w 1.0) + ) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z 8192.0 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z -8192.0 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 7782.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -7782.4 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -8192.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 8192.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -8192.0 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :brake-local-pos (new 'static 'vector :z -8192.0 :w 1.0) + :color-option-count 3 + :color-option-array (new 'static 'inline-array vector 3 + (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 0.7 :w 1.0) + ) + ) + ) + +(define *carb-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 6.0 + :inv-mass 0.16666667 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 3) (meters 4) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*carb-constants* + :flags #x68 + :object-type #xf + :guard-type #x7 + :max-engine-thrust (meters 40) + :inv-max-engine-thrust 0.0000061035157 + :engine-response-rate 10.0 + :engine-intake-factor 1.0 + :brake-factor 2.25 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 4.5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.4 + :air-drag-factor 1.0 + :steering-thruster-factor 3.5 + :steering-thruster-max-gain 3.8 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.55 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000034877234 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.69 + :pitch-control-factor 0.5 + :roll-control-factor 1.0 + :jump-thrust-factor 0.5 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 3) + :turning-accel (meters 20) + :toughness-factor 1.0 + :damage-factor 2.5 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 5461.3335 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 3 + :section-count 4 + :rider-stance #x1 + :grab-rail-count 5 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 5 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 6963.2 :y -2048.0 :z -3276.8 :w 1.0) + (new 'static 'vector :x 6963.2 :y -2048.0 :z 1638.4 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -6963.2 :y -2048.0 :z 1638.4 :w 1.0) + (new 'static 'vector :x -6963.2 :y -2048.0 :z -3276.8 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 4096.0 :y -1638.4 :z 16384.0 :w 1.0) + (new 'static 'vector :x 3891.2 :y -1638.4 :z 16384.0 :w 1.0) + ) + :normal (new 'static 'vector :z 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -3891.2 :y -1638.4 :z 16384.0 :w 1.0) + (new 'static 'vector :x -4096.0 :y -1638.4 :z 16384.0 :w 1.0) + ) + :normal (new 'static 'vector :z 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -819.2 :y 1024.0 :z -12697.6 :w 1.0) + (new 'static 'vector :x 819.2 :y 1024.0 :z -12697.6 :w 1.0) + ) + :normal (new 'static 'vector :z -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :x 4218.88 :y 999.424 :z -172.032 :w (the-as float #x30000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :x -3891.2 :y 999.424 :z -172.032 :w (the-as float #x30000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 3751.936 :z -8192.0 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 122.88 :y -1433.6 :z 614.4 :w 1.0) + (new 'static 'vector :x 122.88 :y 1433.6 :z 614.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x200 #x20 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x400 #x40 #x4) + :damage-seg-count 3 + ) + :section-car-front-right (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x800 #x80 #x8) + :damage-seg-count 3 + ) + :section-car-rear-right (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x1000 #x100 #x10) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-mod-amp 0.025 + :engine-sound-select #x6 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "car-scrape-stn") + :glance-sound (static-sound-name "car-glance-stn") + :impact-sound (static-sound-name "car-impact-stn") + :extra-sound (static-sound-name "car-by-6") + :explosion-part #xa1 + :headlight-count 2 + :taillight-count 2 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 4096.0 :y 1638.4 :z -13107.2 :w 1.0) + (new 'static 'vector :x -4096.0 :y 1638.4 :z -13107.2 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 6553.6 :y 3072.0 :z -10240.0 :w 1.0) + (new 'static 'vector :x -6553.6 :y 3072.0 :z -10240.0 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 4096.0 :y 1638.4 :z -10240.0 :w 1.0) + (new 'static 'vector :x -4096.0 :y 1638.4 :z -10240.0 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 + (new 'static 'vector :x 12288.0 :w 1.0) + (new 'static 'vector :x -12288.0 :w 1.0) + ) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :x 4096.0 :y 2457.6 :z 15155.2 :w 1.0) + (new 'static 'vector :x -4096.0 :y 2457.6 :z 15155.2 :w 1.0) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3891.2 :y 4096.0 :z -12697.6 :w 1.0) + (new 'static 'vector :x -3891.2 :y 4096.0 :z -12697.6 :w 1.0) + ) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z 9011.2 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z -9011.2 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 7782.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -7782.4 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -8192.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 8192.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -8192.0 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :brake-local-pos (new 'static 'vector :z -8192.0 :w 1.0) + :color-option-count 4 + :color-option-array (new 'static 'inline-array vector 4 + (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 0.7 :w 1.0) + (new 'static 'vector :x 0.6 :y 1.0 :z 0.8 :w 1.0) + ) + ) + ) + +(define *carc-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 9.0 + :inv-mass 0.11111111 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :z -4096.0 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 3) (meters 4) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*carc-constants* + :flags #x68 + :object-type #x10 + :guard-type #x7 + :max-engine-thrust (meters 35) + :inv-max-engine-thrust 0.0000069754465 + :engine-response-rate 10.0 + :engine-intake-factor 1.0 + :brake-factor 2.25 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 4.5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.4 + :air-drag-factor 1.0 + :steering-thruster-factor 3.0 + :steering-thruster-max-gain 3.0 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.75 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.7 + :pitch-control-factor 0.5 + :roll-control-factor 1.0 + :jump-thrust-factor 0.5 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters -2) + :turning-accel (meters 15) + :toughness-factor 1.0 + :damage-factor 2.5 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 5461.3335 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 4 + :section-count 4 + :rider-stance #x1 + :grab-rail-count #x9 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 9 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 5324.8 :y -819.2 :z -4096.0 :w 1.0) + (new 'static 'vector :x 5324.8 :y -819.2 :z 2048.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -5324.8 :y -819.2 :z 2048.0 :w 1.0) + (new 'static 'vector :x -5324.8 :y -819.2 :z -4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3276.8 :y -204.8 :z 9830.4 :w 1.0) + (new 'static 'vector :y -204.8 :z 10547.2 :w 1.0) + ) + :normal (new 'static 'vector :z 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :y -204.8 :z 10547.2 :w 1.0) + (new 'static 'vector :x -3276.8 :y -204.8 :z 9830.4 :w 1.0) + ) + :normal (new 'static 'vector :z 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -204.8 :y 3276.8 :z -20889.6 :w 1.0) + (new 'static 'vector :x 204.8 :y 3276.8 :z -20889.6 :w 1.0) + ) + :normal (new 'static 'vector :z -1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3072.0 :y 3481.6 :z -19660.8 :w 1.0) + (new 'static 'vector :x 3891.2 :y 3481.6 :z -16793.6 :w 1.0) + ) + :normal (new 'static 'vector :x 0.707 :z -0.707 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -3891.2 :y 3481.6 :z -16793.6 :w 1.0) + (new 'static 'vector :x -3072.0 :y 3481.6 :z -19660.8 :w 1.0) + ) + :normal (new 'static 'vector :x -0.707 :z -0.707 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 4915.2 :z -14745.6 :w 1.0) + (new 'static 'vector :x 4915.2 :z -12697.6 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -4915.2 :z -12697.6 :w 1.0) + (new 'static 'vector :x -4915.2 :z -14745.6 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 761.856 :z 1368.064 :w (the-as float #x10000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :x -2867.2 :y 1638.4 :z -2867.2 :w (the-as float #x20000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :x 2867.2 :y 1638.4 :z -2867.2 :w (the-as float #x20000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 4239.36 :z -14192.64 :w (the-as float #x40000)) + ) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 696.32 :y -1433.6 :z 614.4 :w 1.0) + (new 'static 'vector :x 696.32 :y 1433.6 :z 614.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x200 #x20 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x400 #x40 #x4) + :damage-seg-count 3 + ) + :section-car-front-right (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x800 #x80 #x8) + :damage-seg-count 3 + ) + :section-car-rear-right (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x1000 #x100 #x10) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-mod-amp 0.025 + :engine-sound-select #x7 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "car-scrape-stn") + :glance-sound (static-sound-name "car-glance-stn") + :impact-sound (static-sound-name "car-impact-stn") + :extra-sound (static-sound-name "car-by-7") + :explosion-part #xa1 + :headlight-count 1 + :taillight-count 2 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3891.2 :z -15155.2 :w 1.0) + (new 'static 'vector :x -3891.2 :z -15155.2 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 3481.6 :z -20480.0 :w 1.0) + (new 'static 'vector :x -2457.6 :y 3481.6 :z -20480.0 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 + (new 'static 'vector :x -0.4 :z -0.92 :w 1.0) + (new 'static 'vector :x 0.4 :z -0.92 :w 1.0) + ) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 4096.0 :y 2048.0 :z -14336.0 :w 1.0) + (new 'static 'vector :x -4096.0 :y 2048.0 :z -14336.0 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 + (new 'static 'vector :x 12288.0 :w 1.0) + (new 'static 'vector :x -12288.0 :w 1.0) + ) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :y 409.6 :z 8601.6 :w 1.0) + (new 'static 'vector) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2867.2 :y 2048.0 :z -18022.4 :w 1.0) + (new 'static 'vector :x -2867.2 :y 2048.0 :z -18022.4 :w 1.0) + ) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 4915.2 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -13107.2 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :z -4096.0 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :z -4096.0 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 3686.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -11878.4 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -12288.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 4096.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -4096.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -12288.0 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -9830.4 :w 1.0) + :brake-local-pos (new 'static 'vector :z -12288.0 :w 1.0) + :color-option-count 4 + :color-option-array (new 'static 'inline-array vector 4 + (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) + (new 'static 'vector :x 0.6 :y 1.2 :z 1.2 :w 1.0) + (new 'static 'vector :x 0.7 :y 1.25 :z 0.8 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.6 :z 1.5 :w 1.0) + ) + ) + ) + +(define *hellcat-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 20.0 + :inv-mass 0.05 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :y 2048.0 :z -2048.0 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 6) (meters 3) (meters 7)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*hellcat-constants* + :flags #x4c + :object-type #x13 + :guard-type #x5 + :max-engine-thrust (meters 30) + :inv-max-engine-thrust 0.000008138021 + :engine-response-rate 8.0 + :engine-intake-factor 1.0 + :brake-factor 2.25 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 30) + :ground-probe-distance (meters 4.5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.3 + :air-drag-factor 1.0 + :steering-thruster-factor 3.0 + :steering-thruster-max-gain 2.0 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.5 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000034877234 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.5 + :pitch-control-factor 0.5 + :roll-control-factor 1.0 + :jump-thrust-factor 0.5 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters -2) + :turning-accel (meters 12) + :toughness-factor 4.0 + :damage-factor 2.0 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 3 + :section-count 4 + :rider-stance #x1 + :grab-rail-count #x6 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 6 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3686.4 :y 409.6 :z 24576.0 :w 1.0) + (new 'static 'vector :x 3276.8 :y 409.6 :z 25395.2 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -3276.8 :y 409.6 :z 25395.2 :w 1.0) + (new 'static 'vector :x -3686.4 :y 409.6 :z 24576.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 8601.6 :z -409.6 :w 1.0) + (new 'static 'vector :x 8601.6 :y -409.6 :z 2867.2 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -8601.6 :y -409.6 :z 2867.2 :w 1.0) + (new 'static 'vector :x -8601.6 :z -409.6 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :y -409.6 :z -15974.4 :w 1.0) + (new 'static 'vector :x 10240.0 :y -409.6 :z -13926.4 :w 1.0) + ) + :normal (new 'static 'vector :z -1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -10240.0 :y -409.6 :z -13926.4 :w 1.0) + (new 'static 'vector :y -409.6 :z -15974.4 :w 1.0) + ) + :normal (new 'static 'vector :z -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :x 5120.0 :y 819.2 :z 2457.6 :w (the-as float #x10000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :x -5120.0 :y 819.2 :z 2457.6 :w (the-as float #x20000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 3686.4 :z -8192.0 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 409.6 :z 4710.4 :w 1.0) + (new 'static 'vector :x -2457.6 :y 409.6 :z 4710.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x200 #x20 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x400 #x40 #x4) + :damage-seg-count 3 + ) + :section-car-front-right (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x800 #x80 #x8) + :damage-seg-count 3 + ) + :section-car-rear-right (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x1000 #x100 #x10) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-mod-amp 0.025 + :engine-sound-select #x8 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "car-scrape-stn") + :glance-sound (static-sound-name "car-glance-stn") + :impact-sound (static-sound-name "car-impact-stn") + :extra-sound (static-sound-name "car-by-8") + :explosion-part #xa1 + :headlight-count 3 + :taillight-count 2 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 6144.0 :y 4096.0 :z -17612.8 :w 1.0) + (new 'static 'vector :x -6144.0 :y 4096.0 :z -17612.8 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 6144.0 :y 5529.6 :z -17612.8 :w 1.0) + (new 'static 'vector :x -6144.0 :y 5529.6 :z -17612.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :y 4096.0 :z -16384.0 :w 1.0) + (new 'static 'vector :x -2048.0 :y 4096.0 :z -16384.0 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :x 5734.4 :y 1843.2 :z 15769.6 :w 1.0) + (new 'static 'vector :x -5734.4 :y 1843.2 :z 15769.6 :w 1.0) + (new 'static 'vector :y 6963.2 :z 6922.24 :w 1.0) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 10362.88 :y 4710.4 :z -16998.4 :w 1.0) + (new 'static 'vector :x -10362.88 :y 4710.4 :z -16998.4 :w 1.0) + ) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 2048.0 :z 8192.0 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 2048.0 :z -12288.0 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 2867.2 :z -2048.0 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 2867.2 :z -2048.0 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 2048.0 :z 5734.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 2048.0 :z -9830.4 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 2048.0 :z -10240.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 2048.0 :z 6144.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 2048.0 :z -2048.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 2048.0 :z -10240.0 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :y 2048.0 :z -7782.4 :w 1.0) + :brake-local-pos (new 'static 'vector :y 2048.0 :z -10240.0 :w 1.0) + :color-option-count 1 + :color-option-array (new 'static 'inline-array vector 1 (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0)) + ) + ) + +(set! (-> *cara-constants* explosion) *car-explosion-info*) + +(set! (-> *carb-constants* explosion) *car-explosion-info*) + +(set! (-> *carc-constants* explosion) *car-explosion-info*) + +(set! (-> *hellcat-constants* explosion) *car-explosion-info*) + +(deftype car-base (vehicle) + ((rider-hand-joint-array int8 2 :offset-assert 880) + ) + :heap-base #x300 + :method-count-assert 144 + :size-assert #x372 + :flag-assert #x9003000372 + ) + + +(defmethod vehicle-method-117 car-base ((obj car-base) (arg0 vector) (arg1 int) (arg2 int)) + (vector-matrix*! + arg0 + (-> obj info-override rider-hand-offset arg2) + (-> obj node-list data (-> obj rider-hand-joint-array arg1) bone transform) + ) + 0 + (none) + ) + +(deftype cara (car-base) + ((steering-wheel-l joint-mod-rotate-local :offset-assert 884) + (steering-wheel-r joint-mod-rotate-local :offset-assert 888) + (fin-fl joint-mod-rotate-local :offset-assert 892) + (fin-fr joint-mod-rotate-local :offset-assert 896) + (fin-rl joint-mod-rotate-local :offset-assert 900) + (fin-rr joint-mod-rotate-local :offset-assert 904) + (rudder-l joint-mod-rotate-local :offset-assert 908) + (rudder-r joint-mod-rotate-local :offset-assert 912) + (rudder joint-mod-rotate-local :offset-assert 916) + ) + :heap-base #x320 + :method-count-assert 144 + :size-assert #x398 + :flag-assert #x9003200398 + ) + + +(defmethod relocate cara ((obj cara) (arg0 int)) + (if (nonzero? (-> obj steering-wheel-l)) + (&+! (-> obj steering-wheel-l) arg0) + ) + (if (nonzero? (-> obj steering-wheel-r)) + (&+! (-> obj steering-wheel-r) arg0) + ) + (if (nonzero? (-> obj fin-fl)) + (&+! (-> obj fin-fl) arg0) + ) + (if (nonzero? (-> obj fin-fr)) + (&+! (-> obj fin-fr) arg0) + ) + (if (nonzero? (-> obj fin-rl)) + (&+! (-> obj fin-rl) arg0) + ) + (if (nonzero? (-> obj fin-rr)) + (&+! (-> obj fin-rr) arg0) + ) + (if (nonzero? (-> obj rudder)) + (&+! (-> obj rudder) arg0) + ) + (if (nonzero? (-> obj rudder-l)) + (&+! (-> obj rudder-l) arg0) + ) + (if (nonzero? (-> obj rudder-r)) + (&+! (-> obj rudder-r) arg0) + ) + ((the-as (function object object cara) (find-parent-method cara 7)) obj arg0) + ) + +(defmethod allocate-and-init-cshape cara ((obj cara)) + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-default) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate vehicle)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 7) 0))) + (set! (-> s5-0 total-prims) (the-as uint 8)) + (set! (-> s4-0 prim-core action) (collide-action solid rideable)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 18432.0) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-11 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-11 prim-core action) (collide-action solid)) + (set! (-> v1-11 transform-index) 0) + (set-vector! (-> v1-11 local-sphere) 3686.4 0.0 12288.0 4096.0) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 4)))) + (set! (-> v1-13 prim-core action) (collide-action solid)) + (set! (-> v1-13 transform-index) 0) + (set-vector! (-> v1-13 local-sphere) -3686.4 0.0 12288.0 4096.0) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 5)))) + (set! (-> v1-15 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-15 transform-index) 0) + (set-vector! (-> v1-15 local-sphere) 0.0 819.2 5734.4 4915.2) + (set! (-> v1-15 nav-radius) 14336.0) + ) + (let ((v1-17 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 80)))) + (set! (-> v1-17 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-17 transform-index) 0) + (set-vector! (-> v1-17 local-sphere) 0.0 2048.0 -4096.0 5734.4) + (set! (-> v1-17 nav-radius) 14336.0) + ) + (let ((v1-19 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-19 prim-core action) (collide-action solid)) + (set! (-> v1-19 transform-index) 0) + (set-vector! (-> v1-19 local-sphere) 4915.2 0.0 -11468.8 4096.0) + ) + (let ((v1-21 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 8)))) + (set! (-> v1-21 prim-core action) (collide-action solid)) + (set! (-> v1-21 transform-index) 0) + (set-vector! (-> v1-21 local-sphere) -4915.2 0.0 -11468.8 4096.0) + ) + (let ((v1-23 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 0) (the-as uint 0)))) + (set! (-> v1-23 prim-core action) (collide-action solid rideable)) + (set! (-> v1-23 transform-index) 3) + (set-vector! (-> v1-23 local-sphere) 0.0 0.0 0.0 18432.0) + ) + (set! (-> s5-0 nav-radius) 20480.0) + (let ((v1-25 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-25 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-25 prim-core collide-with)) + ) + (set! (-> s5-0 nav-flags) (nav-flags has-child-spheres)) + (set! (-> obj root-override-2) s5-0) + ) + 0 + (none) + ) + +(defmethod update-joint-mods cara ((obj cara)) + (let ((f30-0 (* 3640.889 (-> obj controls steering))) + (f26-0 (* 9102.223 (-> obj controls steering))) + (f28-0 (* -3640.889 (-> obj controls lean-z))) + (s5-0 (new 'static 'vector :x 1.0 :w 1.0)) + ) + (quaternion-vector-angle! (-> obj steering-wheel-l rotation) s5-0 f26-0) + (quaternion-vector-angle! (-> obj steering-wheel-r rotation) s5-0 f26-0) + (quaternion-vector-angle! (-> obj fin-fl rotation) s5-0 (- f28-0)) + (quaternion-vector-angle! (-> obj fin-fr rotation) s5-0 f28-0) + (quaternion-vector-angle! (-> obj fin-rl rotation) s5-0 f28-0) + (quaternion-vector-angle! (-> obj fin-rr rotation) s5-0 (- f28-0)) + (quaternion-vector-angle! (-> obj rudder rotation) s5-0 f30-0) + ) + 0 + (none) + ) + +(defmethod init-skel-and-rigid-body cara ((obj cara)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-cara" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *cara-constants*) + (set! (-> obj rider-hand-joint-array 0) 11) + (set! (-> obj rider-hand-joint-array 1) 12) + (set! (-> obj steering-wheel-l) (new 'process 'joint-mod-rotate-local obj 11 #t)) + (set! (-> obj steering-wheel-r) (new 'process 'joint-mod-rotate-local obj 12 #t)) + (set! (-> obj fin-fl) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj fin-fr) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj rudder) (new 'process 'joint-mod-rotate-local obj 10 #t)) + (set! (-> obj rudder-l) (new 'process 'joint-mod-rotate-local obj 7 #t)) + (set! (-> obj rudder-r) (new 'process 'joint-mod-rotate-local obj 9 #t)) + 0 + (none) + ) + +(deftype carb (car-base) + ((steering-wheel-l joint-mod-rotate-local :offset-assert 884) + (steering-wheel-r joint-mod-rotate-local :offset-assert 888) + (fin-fl joint-mod-rotate-local :offset-assert 892) + (fin-fr joint-mod-rotate-local :offset-assert 896) + (fin-rl joint-mod-rotate-local :offset-assert 900) + (fin-rr joint-mod-rotate-local :offset-assert 904) + ) + :heap-base #x310 + :method-count-assert 144 + :size-assert #x38c + :flag-assert #x900310038c + ) + + +(defmethod relocate carb ((obj carb) (arg0 int)) + (if (nonzero? (-> obj steering-wheel-l)) + (&+! (-> obj steering-wheel-l) arg0) + ) + (if (nonzero? (-> obj steering-wheel-r)) + (&+! (-> obj steering-wheel-r) arg0) + ) + (if (nonzero? (-> obj fin-fl)) + (&+! (-> obj fin-fl) arg0) + ) + (if (nonzero? (-> obj fin-fr)) + (&+! (-> obj fin-fr) arg0) + ) + (if (nonzero? (-> obj fin-rl)) + (&+! (-> obj fin-rl) arg0) + ) + (if (nonzero? (-> obj fin-rr)) + (&+! (-> obj fin-rr) arg0) + ) + ((the-as (function object object carb) (find-parent-method carb 7)) obj arg0) + ) + +(defmethod allocate-and-init-cshape carb ((obj carb)) + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-default) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate vehicle)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 7) 0))) + (set! (-> s5-0 total-prims) (the-as uint 8)) + (set! (-> s4-0 prim-core action) (collide-action solid rideable)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 18432.0) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-11 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-11 prim-core action) (collide-action solid)) + (set! (-> v1-11 transform-index) 0) + (set-vector! (-> v1-11 local-sphere) 3686.4 409.6 13107.2 3686.4) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 4)))) + (set! (-> v1-13 prim-core action) (collide-action solid)) + (set! (-> v1-13 transform-index) 0) + (set-vector! (-> v1-13 local-sphere) -3686.4 409.6 13107.2 3686.4) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-15 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-15 transform-index) 0) + (set-vector! (-> v1-15 local-sphere) 0.0 819.2 6553.6 4096.0) + (set! (-> v1-15 nav-radius) 14336.0) + ) + (let ((v1-17 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 64)))) + (set! (-> v1-17 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-17 transform-index) 0) + (set-vector! (-> v1-17 local-sphere) 0.0 2457.6 -2457.6 5734.4) + (set! (-> v1-17 nav-radius) 14336.0) + ) + (let ((v1-19 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-19 prim-core action) (collide-action solid)) + (set! (-> v1-19 transform-index) 0) + (set-vector! (-> v1-19 local-sphere) 4505.6 409.6 -11059.2 3686.4) + ) + (let ((v1-21 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 8)))) + (set! (-> v1-21 prim-core action) (collide-action solid)) + (set! (-> v1-21 transform-index) 0) + (set-vector! (-> v1-21 local-sphere) -4505.6 409.6 -11059.2 3686.4) + ) + (let ((v1-23 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 0) (the-as uint 0)))) + (set! (-> v1-23 prim-core action) (collide-action solid rideable)) + (set! (-> v1-23 transform-index) 3) + (set-vector! (-> v1-23 local-sphere) 0.0 0.0 0.0 18432.0) + ) + (set! (-> s5-0 nav-radius) 20480.0) + (let ((v1-25 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-25 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-25 prim-core collide-with)) + ) + (set! (-> s5-0 nav-flags) (nav-flags has-child-spheres)) + (set! (-> obj root-override-2) s5-0) + ) + 0 + (none) + ) + +(defmethod update-joint-mods carb ((obj carb)) + (let ((f30-0 (* -5461.3335 (-> obj controls lean-z))) + (f28-0 (* 9102.223 (-> obj controls steering))) + (gp-0 (new 'static 'vector :x 1.0 :w 1.0)) + ) + (quaternion-vector-angle! (-> obj steering-wheel-l rotation) gp-0 f28-0) + (quaternion-vector-angle! (-> obj steering-wheel-r rotation) gp-0 f28-0) + (quaternion-vector-angle! (-> obj fin-fl rotation) gp-0 (+ (* -0.8 f30-0) (* 0.4 f28-0))) + (quaternion-vector-angle! (-> obj fin-fr rotation) gp-0 (+ (* 0.8 f30-0) (* 0.4 f28-0))) + (quaternion-vector-angle! (-> obj fin-rl rotation) gp-0 (+ (* 0.8 f30-0) (* 0.4 f28-0))) + (quaternion-vector-angle! (-> obj fin-rr rotation) gp-0 (+ (* -0.8 f30-0) (* 0.4 f28-0))) + ) + 0 + (none) + ) + +(defmethod init-skel-and-rigid-body carb ((obj carb)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-carb" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *carb-constants*) + (set! (-> obj rider-hand-joint-array 0) 8) + (set! (-> obj rider-hand-joint-array 1) 9) + (set! (-> obj steering-wheel-l) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj steering-wheel-r) (new 'process 'joint-mod-rotate-local obj 9 #t)) + (set! (-> obj fin-fl) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj fin-fr) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 7 #t)) + 0 + (none) + ) + +(deftype carc (car-base) + ((steering-wheel joint-mod-rotate-local :offset-assert 884) + (fin-fl joint-mod-rotate-local :offset-assert 888) + (fin-fr joint-mod-rotate-local :offset-assert 892) + (fin-rl joint-mod-rotate-local :offset-assert 896) + (fin-rr joint-mod-rotate-local :offset-assert 900) + (fin2-rl joint-mod-rotate-local :offset-assert 904) + (fin2-rr joint-mod-rotate-local :offset-assert 908) + ) + :heap-base #x310 + :method-count-assert 144 + :size-assert #x390 + :flag-assert #x9003100390 + ) + + +;; WARN: Return type mismatch carb vs carc. +(defmethod relocate carc ((obj carc) (arg0 int)) + (if (nonzero? (-> obj steering-wheel)) + (&+! (-> obj steering-wheel) arg0) + ) + (if (nonzero? (-> obj fin-fl)) + (&+! (-> obj fin-fl) arg0) + ) + (if (nonzero? (-> obj fin-fr)) + (&+! (-> obj fin-fr) arg0) + ) + (if (nonzero? (-> obj fin-rl)) + (&+! (-> obj fin-rl) arg0) + ) + (if (nonzero? (-> obj fin-rr)) + (&+! (-> obj fin-rr) arg0) + ) + (if (nonzero? (-> obj fin2-rl)) + (&+! (-> obj fin2-rl) arg0) + ) + (if (nonzero? (-> obj fin2-rr)) + (&+! (-> obj fin2-rr) arg0) + ) + (the-as carc ((the-as (function object object carb) (find-parent-method carc 7)) obj arg0)) + ) + +(defmethod allocate-and-init-cshape carc ((obj carc)) + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-default) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate vehicle)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 6) 0))) + (set! (-> s5-0 total-prims) (the-as uint 7)) + (set! (-> s4-0 prim-core action) (collide-action solid rideable)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 21299.2) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-11 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-11 prim-core action) (collide-action solid)) + (set! (-> v1-11 transform-index) 0) + (set-vector! (-> v1-11 local-sphere) 3686.4 -819.2 6963.2 3276.8) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 4)))) + (set! (-> v1-13 prim-core action) (collide-action solid)) + (set! (-> v1-13 transform-index) 0) + (set-vector! (-> v1-13 local-sphere) -3686.4 -819.2 6963.2 3276.8) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 64)))) + (set! (-> v1-15 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-15 transform-index) 0) + (set-vector! (-> v1-15 local-sphere) 0.0 2457.6 0.0 6144.0) + (set! (-> v1-15 nav-radius) 12288.0) + ) + (let ((v1-17 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 10)))) + (set! (-> v1-17 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-17 transform-index) 0) + (set-vector! (-> v1-17 local-sphere) 0.0 2048.0 -10240.0 4915.2) + (set! (-> v1-17 nav-radius) 10240.0) + ) + (let ((v1-19 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 10)))) + (set! (-> v1-19 prim-core action) (collide-action solid)) + (set! (-> v1-19 transform-index) 0) + (set-vector! (-> v1-19 local-sphere) 0.0 2048.0 -16384.0 4096.0) + ) + (let ((v1-21 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 0) (the-as uint 0)))) + (set! (-> v1-21 prim-core action) (collide-action solid rideable)) + (set! (-> v1-21 transform-index) 3) + (set-vector! (-> v1-21 local-sphere) 0.0 0.0 0.0 21299.2) + ) + (set! (-> s5-0 nav-radius) 16384.0) + (let ((v1-23 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-23 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-23 prim-core collide-with)) + ) + (set! (-> s5-0 nav-flags) (nav-flags has-child-spheres)) + (set! (-> obj root-override-2) s5-0) + ) + 0 + (none) + ) + +(defmethod update-joint-mods carc ((obj carc)) + (let ((f30-0 (* -5461.3335 (-> obj controls steering))) + (f28-0 (* -5461.3335 (-> obj controls lean-z))) + (f0-3 (* 9102.223 (-> obj controls steering))) + (s5-0 (new 'static 'vector :x 1.0 :w 1.0)) + ) + (quaternion-vector-angle! (-> obj steering-wheel rotation) s5-0 f0-3) + (quaternion-vector-angle! (-> obj fin-fl rotation) s5-0 (- f28-0)) + (quaternion-vector-angle! (-> obj fin-fr rotation) s5-0 f28-0) + (quaternion-vector-angle! (-> obj fin-rl rotation) s5-0 (+ (* 0.8 f28-0) (* -0.2 f30-0))) + (quaternion-vector-angle! (-> obj fin-rr rotation) s5-0 (+ (* -0.8 f28-0) (* -0.2 f30-0))) + (quaternion-vector-angle! (-> obj fin2-rl rotation) s5-0 (+ (* 0.2 f28-0) (* -0.8 f30-0))) + (quaternion-vector-angle! (-> obj fin2-rr rotation) s5-0 (+ (* -0.2 f28-0) (* -0.8 f30-0))) + ) + 0 + (none) + ) + +(defmethod init-skel-and-rigid-body carc ((obj carc)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-carc" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *carc-constants*) + (set! (-> obj rider-hand-joint-array 0) 10) + (set! (-> obj steering-wheel) (new 'process 'joint-mod-rotate-local obj 10 #t)) + (set! (-> obj fin-fl) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj fin-fr) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 9 #t)) + (set! (-> obj fin2-rl) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj fin2-rr) (new 'process 'joint-mod-rotate-local obj 7 #t)) + 0 + (none) + ) + +(define *hellcat-front-turret-control-info* (new 'static 'turret-control-info + :joint-index 4 + :barrel-count 1 + :shot-speed 819200.0 + :attack-range 286720.0 + :rot-min (new 'static 'array float 2 -16384.0 -21845.334) + :rot-max (new 'static 'array float 2 0.0 21845.334) + :local-pos (new 'static 'vector :y -1433.6 :z 4096.0 :w 1.0) + :local-dir (new 'static 'vector :z 1.0 :w 1.0) + :barrel-array (new 'static 'inline-array turret-barrel-info 4 + (new 'static 'turret-barrel-info + :local-pos (new 'static 'vector :y -1433.6 :z 4096.0 :w 1.0) + :local-dir (new 'static 'vector :z 1.0 :w 1.0) + ) + (new 'static 'turret-barrel-info) + (new 'static 'turret-barrel-info) + (new 'static 'turret-barrel-info) + ) + ) + ) + +(deftype hellcat (vehicle-guard) + ((turret-jm joint-mod-rotate-local :offset-assert 1076) + ) + :heap-base #x3c0 + :method-count-assert 159 + :size-assert #x438 + :flag-assert #x9f03c00438 + ) + + +(defmethod relocate hellcat ((obj hellcat) (arg0 int)) + (if (nonzero? (-> obj turret-jm)) + (&+! (-> obj turret-jm) arg0) + ) + ((the-as (function object object hellcat) (find-parent-method hellcat 7)) obj arg0) + ) + +(defmethod allocate-and-init-cshape hellcat ((obj hellcat)) + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-default) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate vehicle)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 7) 0))) + (set! (-> s5-0 total-prims) (the-as uint 8)) + (set! (-> s4-0 prim-core action) (collide-action solid rideable)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 26624.0) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-11 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-11 prim-core action) (collide-action solid)) + (set! (-> v1-11 transform-index) 0) + (set-vector! (-> v1-11 local-sphere) 4096.0 1228.8 9011.2 6144.0) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 4)))) + (set! (-> v1-13 prim-core action) (collide-action solid)) + (set! (-> v1-13 transform-index) 0) + (set-vector! (-> v1-13 local-sphere) -4096.0 1228.8 9011.2 6144.0) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0)))) + (set! (-> v1-15 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-15 transform-index) 0) + (set-vector! (-> v1-15 local-sphere) 0.0 2048.0 -409.6 6144.0) + (set! (-> v1-15 nav-radius) 24576.0) + ) + (let ((v1-17 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 10)))) + (set! (-> v1-17 prim-core action) (collide-action solid)) + (set! (-> v1-17 transform-index) 0) + (set-vector! (-> v1-17 local-sphere) 0.0 4096.0 -10240.0 8192.0) + ) + (let ((v1-19 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-19 prim-core action) (collide-action solid)) + (set! (-> v1-19 transform-index) 0) + (set-vector! (-> v1-19 local-sphere) 10240.0 2048.0 -8192.0 6144.0) + ) + (let ((v1-21 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 8)))) + (set! (-> v1-21 prim-core action) (collide-action solid)) + (set! (-> v1-21 transform-index) 0) + (set-vector! (-> v1-21 local-sphere) -10240.0 2048.0 -8192.0 6144.0) + ) + (let ((v1-23 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 0) (the-as uint 0)))) + (set! (-> v1-23 prim-core action) (collide-action solid rideable)) + (set! (-> v1-23 transform-index) 3) + (set-vector! (-> v1-23 local-sphere) 0.0 0.0 0.0 26624.0) + ) + (set! (-> s5-0 nav-radius) 20480.0) + (let ((v1-25 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-25 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-25 prim-core collide-with)) + ) + (set! (-> s5-0 nav-flags) (nav-flags has-child-spheres)) + (set! (-> obj root-override-2) s5-0) + ) + 0 + (none) + ) + +(defmethod update-joint-mods hellcat ((obj hellcat)) + (update-joint-mod (-> obj turret) (-> obj turret-jm)) + 0 + (none) + ) + +(defmethod init-skel-and-rigid-body hellcat ((obj hellcat)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-hellcat" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *hellcat-constants*) + (set-info (-> obj turret) *hellcat-front-turret-control-info*) + (set! (-> obj turret-jm) (new 'process 'joint-mod-rotate-local obj (-> obj turret info joint-index) #t)) + 0 + (none) + ) diff --git a/goal_src/jak2/levels/city/common/citizen-chick.gc b/goal_src/jak2/levels/city/common/citizen-chick.gc index 86786c3b32..b0b8bb5d3e 100644 --- a/goal_src/jak2/levels/city/common/citizen-chick.gc +++ b/goal_src/jak2/levels/city/common/citizen-chick.gc @@ -5,5 +5,15 @@ ;; name in dgo: citizen-chick ;; dgos: CWI +(deftype citizen-chick (civilian) + () + :method-count-assert 218 + :size-assert #x424 + :flag-assert #xda03b00424 + (:methods + ) + ) + + ;; DECOMP BEGINS diff --git a/goal_src/jak2/levels/city/common/citizen-enemy.gc b/goal_src/jak2/levels/city/common/citizen-enemy.gc index d414313326..67d80f1fd0 100644 --- a/goal_src/jak2/levels/city/common/citizen-enemy.gc +++ b/goal_src/jak2/levels/city/common/citizen-enemy.gc @@ -5,5 +5,19 @@ ;; name in dgo: citizen-enemy ;; dgos: CWI +(deftype citizen-enemy (citizen) + ((next-update-target uint64 :offset-assert 968) + (minimap connection-minimap :offset-assert 976) + ) + :method-count-assert 203 + :size-assert #x3d4 + :flag-assert #xcb036003d4 + (:methods + (citizen-enemy-method-201 () none 201) + (citizen-enemy-method-202 () none 202) + ) + ) + + ;; DECOMP BEGINS diff --git a/goal_src/jak2/levels/city/common/citizen-norm.gc b/goal_src/jak2/levels/city/common/citizen-norm.gc index df15b22e2b..2b84d34372 100644 --- a/goal_src/jak2/levels/city/common/citizen-norm.gc +++ b/goal_src/jak2/levels/city/common/citizen-norm.gc @@ -5,5 +5,15 @@ ;; name in dgo: citizen-norm ;; dgos: CWI +(deftype citizen-norm (civilian) + () + :method-count-assert 219 + :size-assert #x424 + :flag-assert #xdb03b00424 + (:methods + (knocked-off-vehicle () _type_ :state 218) + ) + ) + ;; DECOMP BEGINS diff --git a/goal_src/jak2/levels/city/common/ctyport-obs.gc b/goal_src/jak2/levels/city/common/ctyport-obs.gc index 7b45f5c29f..99ca838616 100644 --- a/goal_src/jak2/levels/city/common/ctyport-obs.gc +++ b/goal_src/jak2/levels/city/common/ctyport-obs.gc @@ -447,7 +447,7 @@ 0 ) ) - (vehicle-method-85 obj) + (draw-thrusters obj) (none) ) ) @@ -523,7 +523,7 @@ (none) ) -(defmethod rigid-body-object-method-36 boat-base ((obj boat-base)) +(defmethod do-engine-sounds boat-base ((obj boat-base)) 0 (none) ) @@ -569,8 +569,8 @@ (none) ) -(defmethod rigid-body-object-method-31 boat-base ((obj boat-base) (arg0 rigid-body-vehicle-constants)) - ((method-of-type vehicle rigid-body-object-method-31) obj arg0) +(defmethod alloc-and-init-rigid-body-control boat-base ((obj boat-base) (arg0 rigid-body-vehicle-constants)) + ((method-of-type vehicle alloc-and-init-rigid-body-control) obj arg0) 0 (none) ) @@ -710,7 +710,7 @@ ) ) -(defmethod rigid-body-object-method-32 barge ((obj barge)) +(defmethod allocate-and-init-cshape barge ((obj barge)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -830,13 +830,13 @@ (none) ) -(defmethod rigid-body-object-method-33 barge ((obj barge)) +(defmethod init-skel-and-rigid-body barge ((obj barge)) (initialize-skeleton obj (the-as skeleton-group (art-group-get-by-name *level* "skel-barge" (the-as (pointer uint32) #f))) (the-as pair 0) ) - (rigid-body-object-method-31 obj *barge-constants*) + (alloc-and-init-rigid-body-control obj *barge-constants*) (set! (-> obj draw lod-set lod 0 dist) 1228800.0) (set! (-> obj engine) (the-as uint (new-sound-id))) (set! (-> obj bow-wash) (the-as uint (new-sound-id))) diff --git a/goal_src/jak2/levels/city/common/ctywide-obs-h.gc b/goal_src/jak2/levels/city/common/ctywide-obs-h.gc index 02f3a869ce..0e3856af75 100644 --- a/goal_src/jak2/levels/city/common/ctywide-obs-h.gc +++ b/goal_src/jak2/levels/city/common/ctywide-obs-h.gc @@ -5,6 +5,8 @@ ;; name in dgo: ctywide-obs-h ;; dgos: CWI +(define-extern restore-city-speeches (function none)) + ;; DECOMP BEGINS (deftype city-race-ring-info (structure) diff --git a/goal_src/jak2/levels/city/common/ctywide-speech.gc b/goal_src/jak2/levels/city/common/ctywide-speech.gc index 5601ea706d..b83a89d74a 100644 --- a/goal_src/jak2/levels/city/common/ctywide-speech.gc +++ b/goal_src/jak2/levels/city/common/ctywide-speech.gc @@ -5,5 +5,9 @@ ;; name in dgo: ctywide-speech ;; dgos: CWI +;; hack +(defun restore-city-speeches () + (none) + ) ;; DECOMP BEGINS diff --git a/goal_src/jak2/levels/city/common/guard.gc b/goal_src/jak2/levels/city/common/guard.gc index c7386c656f..0316a2dc8e 100644 --- a/goal_src/jak2/levels/city/common/guard.gc +++ b/goal_src/jak2/levels/city/common/guard.gc @@ -5,5 +5,121 @@ ;; name in dgo: guard ;; dgos: CWI +;; stub for now + +(deftype guard-anim-info (structure) + ((anim-index int32 2 :offset-assert 0) + (anim-index-front int32 :offset 0) + (anim-index-back int32 :offset 4) + ) + :method-count-assert 9 + :size-assert #x8 ;; 8 + :flag-assert #x900000008 + ) + +#| +(deftype guard-global-info (UNKNOWN) + ((prev-yellow-hit int8 :offset-assert 4) + (prev-blue-hit int8 :offset-assert 5) + (knocked UNKNOWN 2 :offset-assert 8) + (knocked-land UNKNOWN 2 :offset-assert 16) + (anim-knocked-front int32 :offset-assert 8) + (anim-knocked-back int32 :offset-assert 12) + (anim-knocked-front-land int32 :offset-assert 16) + (anim-knocked-back-land int32 :offset-assert 20) + (yellow-hit-anim UNKNOWN 2 :offset-assert 24) + (yellow-land-anim UNKNOWN 2 :offset-assert 40) + (blue-hit-anim UNKNOWN 1 :offset-assert 56) + ) + :method-count-assert 0 + :size-assert #x0 + :flag-assert #x0 + ) +|# + +(deftype guard-shoot-info (structure) + ((anim-index int32 :offset-assert 0) + (start float :offset-assert 4) + (end float :offset-assert 8) + ) + :pack-me + :method-count-assert 9 + :size-assert #xc ;; 12 + :flag-assert #x90000000c + ) + +(deftype crimson-guard (citizen) + ( + (info symbol :offset-assert 964) + (hit-face uint32 :offset-assert 968) + (anim-get-up-front int32 :offset-assert 972) + (anim-get-up-back int32 :offset-assert 976) + (small-hit int32 :offset-assert 980) + (yellow-anim uint32 :offset-assert 984) + (guard-type uint8 :offset-assert 988) + (settings traffic-guard-type-settings :offset-assert 992) + (next-time time-frame :offset-assert 1000) + (last-time-see-target time-frame :offset-assert 1008) + (joint symbol :offset-assert 1016) + (joint-enable symbol :offset-assert 1020) + (already-shot symbol :offset-assert 1024) + (miss-amount float :offset-assert 1028) + (l-control symbol :offset-assert 1032) + (next-shot int64 :offset-assert 1040) + (anim-shoot guard-shoot-info 3 :inline :offset-assert 1048) ;; elt size: 13.333333333333334 + (transport int64 :offset-assert 1088) + (transport-side uint32 :offset-assert 1096) + (target-flags uint8 :offset-assert 1100) + (target-pos vector :inline :offset-assert 1104) + (target-pos-predict vector :inline :offset-assert 1120) + (target-pos-predict-miss vector :inline :offset-assert 1136) + (target-vel-vec vector :inline :offset-assert 1152) + (target-vel float :offset-assert 1168) + (target-self vector :inline :offset-assert 1184) + (target-self-xz vector :inline :offset-assert 1200) + (target-self-dist float :offset-assert 1216) + (target-self-xz-dist float :offset-assert 1220) + (target-y-angle degrees :offset-assert 1224) + (last-visible-target-pos vector :inline :offset-assert 1232) + (lazer-sound uint32 :offset-assert 1248) + (move-position vector :inline :offset-assert 1264) + (move-index int32 :offset-assert 1280) + (traffic-target-status traffic-target-status :inline :offset-assert 1296) + (minimap connection-minimap :offset-assert 1376) + (other-side symbol :offset-assert 1380) + ) + :method-count-assert 227 + :size-assert #x568 ;; 1384 + :flag-assert #xe304f00568 + (:methods + (crimson-guard-method-201 () none 201) + (crimson-guard-method-202 () none 202) + (crimson-guard-method-203 () none 203) + (crimson-guard-method-204 () none 204) + (crimson-guard-method-205 () none 205) + (crimson-guard-method-206 () none 206) + (crimson-guard-method-207 () none 207) + (crimson-guard-method-208 () none 208) + (crimson-guard-method-209 () none 209) + (crimson-guard-method-210 () none 210) + (crimson-guard-method-211 () none 211) + (crimson-guard-method-212 () none 212) + (crimson-guard-method-213 () none 213) + (crimson-guard-method-214 () none 214) + (crimson-guard-method-215 () none 215) + (crimson-guard-method-216 () none 216) + (crimson-guard-method-217 () none 217) + (crimson-guard-method-218 () none 218) + (crimson-guard-method-219 () none 219) + (crimson-guard-method-220 () none 220) + (crimson-guard-method-221 () none 221) + (crimson-guard-method-222 () none 222) + (crimson-guard-method-223 () none 223) + (crimson-guard-method-224 () none 224) + (crimson-guard-method-225 () none 225) + (crimson-guard-method-226 () none 226)) + ) + + ;; DECOMP BEGINS diff --git a/goal_src/jak2/levels/city/common/height-map-h.gc b/goal_src/jak2/levels/city/common/height-map-h.gc index 5dc1a91be0..2a64361d9d 100644 --- a/goal_src/jak2/levels/city/common/height-map-h.gc +++ b/goal_src/jak2/levels/city/common/height-map-h.gc @@ -30,12 +30,12 @@ all initialized from static data." :size-assert #x20 :flag-assert #xf00000020 (:methods - (xz-height-map-method-9 (_type_ vector) float 9) - (xz-height-map-method-10 (_type_ vector) none 10) - (xz-height-map-method-11 (_type_) none 11) - (xz-height-map-method-12 (_type_ vector) none 12) - (xz-height-map-method-13 (_type_ vector) none 13) - (xz-height-map-method-14 (_type_ vector int) none 14) + (get-height-at-point (_type_ vector) float 9) + (debug-draw-mesh (_type_ vector) none 10) + (debug-print (_type_) none 11) + (debug-draw-at-point (_type_ vector) none 12) + (debug-draw (_type_ vector) none 13) + (debug-add-offset (_type_ vector int) none 14) ) ) @@ -43,5 +43,5 @@ all initialized from static data." (defun get-traffic-height ((arg0 vector)) "@returns The value of [[xz-height-map::9]] using [[*traffic-height-map*]] and the [[vector]] provided @see [[xz-height-map::9]]" - (xz-height-map-method-9 *traffic-height-map* arg0) + (get-height-at-point *traffic-height-map* arg0) ) diff --git a/goal_src/jak2/levels/city/common/height-map.gc b/goal_src/jak2/levels/city/common/height-map.gc index 74f8f33806..6fdcccbf6f 100644 --- a/goal_src/jak2/levels/city/common/height-map.gc +++ b/goal_src/jak2/levels/city/common/height-map.gc @@ -7,3 +7,247 @@ ;; DECOMP BEGINS +(defmethod debug-print xz-height-map ((obj xz-height-map)) + (format #t "(define *traffic-height-map*~%") + (format #t " (static-height-map~%") + (format + #t + " :offset ((meters ~M) (meters ~M) (meters ~M))~%" + (-> obj x-offset) + (-> obj y-offset) + (-> obj z-offset) + ) + (format #t " :x-spacing (meters ~M)~%" (/ 1.0 (-> obj x-inv-spacing))) + (format #t " :z-spacing (meters ~M)~%" (/ 1.0 (-> obj z-inv-spacing))) + (format #t " :y-scale (meters ~M)~%" (-> obj y-scale)) + (format #t " :x-dim ~d~%" (-> obj x-dim)) + (format #t " :z-dim ~d~%" (-> obj z-dim)) + (format #t " :data~%") + (format #t " (~%") + (let ((s5-0 0)) + (dotimes (s4-0 (-> obj z-dim)) + (dotimes (s3-0 (-> obj x-dim)) + (format #t " ~2d" (-> obj data s5-0)) + (+! s5-0 1) + ) + (format #t "~%") + ) + ) + (format #t "~T)~%") + (format #t " )~%") + (format #t " )~%~%") + 0 + (none) + ) + +(defmethod debug-add-offset xz-height-map ((obj xz-height-map) (arg0 vector) (arg1 int)) + "Add an offset to the given point, likely for debugging purposes." + (let ((v1-1 (the int (+ 0.5 (* (- (-> arg0 x) (-> obj x-offset)) (-> obj x-inv-spacing))))) + (a1-1 (the int (+ 0.5 (* (- (-> arg0 z) (-> obj z-offset)) (-> obj z-inv-spacing))))) + ) + (when (and (>= v1-1 0) (< v1-1 (-> obj x-dim)) (>= a1-1 0) (< a1-1 (-> obj z-dim))) + (let ((v1-2 (+ v1-1 (* a1-1 (-> obj x-dim))))) + (+! (-> obj data v1-2) arg1) + ) + ) + ) + 0 + (none) + ) + +(defmethod debug-draw-at-point xz-height-map ((obj xz-height-map) (arg0 vector)) + (let ((v1-1 (the int (+ 0.5 (* (- (-> arg0 x) (-> obj x-offset)) (-> obj x-inv-spacing))))) + (a1-1 (the int (+ 0.5 (* (- (-> arg0 z) (-> obj z-offset)) (-> obj z-inv-spacing))))) + (a2-1 (-> obj x-dim)) + (a3-0 (-> obj z-dim)) + ) + (when (and (>= v1-1 0) (< v1-1 a2-1) (>= a1-1 0) (< a1-1 a3-0)) + (let* ((a2-3 (+ v1-1 (* a1-1 a2-1))) + (gp-0 (-> obj data a2-3)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s5-0 x) (+ (-> obj x-offset) (/ (the float v1-1) (-> obj x-inv-spacing)))) + (set! (-> s5-0 y) 0.0) + (set! (-> s5-0 z) (+ (-> obj z-offset) (/ (the float a1-1) (-> obj z-inv-spacing)))) + (set! (-> s5-0 y) (get-height-at-point obj s5-0)) + (let ((s4-0 add-debug-text-3d) + (s3-0 #t) + (s2-0 318) + ) + (format (clear *temp-string*) "~D" gp-0) + (s4-0 + s3-0 + (the-as bucket-id s2-0) + *temp-string* + s5-0 + (font-color #dadada) + (new 'static 'vector2h :data (new 'static 'array int16 2 0 16)) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod get-height-at-point xz-height-map ((obj xz-height-map) (arg0 vector)) + (let* ((f0-1 (fmax 0.0 (* (-> obj x-inv-spacing) (- (-> arg0 x) (-> obj x-offset))))) + (f2-4 (fmax 0.0 (* (-> obj z-inv-spacing) (- (-> arg0 z) (-> obj z-offset))))) + (a2-0 (the int f0-1)) + (a1-1 (the int f2-4)) + (f1-7 (- f0-1 (the float a2-0))) + (f0-4 (- f2-4 (the float a1-1))) + (v1-0 (-> obj x-dim)) + (a3-0 (-> obj z-dim)) + (a1-7 + (the-as + (pointer int8) + (+ (+ (min a2-0 (+ v1-0 -2)) (* (min a1-1 (+ a3-0 -2)) v1-0) 0) (the-as int (the-as pointer (-> obj data)))) + ) + ) + (f3-3 (the float (-> a1-7 0))) + (f4-1 (the float (-> a1-7 1))) + (f2-8 (the float (-> a1-7 v1-0))) + (f5-1 (the float (-> a1-7 (+ v1-0 1)))) + (f3-5 (+ (* f3-3 (- 1.0 f1-7)) (* f4-1 f1-7))) + (f1-9 (+ (* f2-8 (- 1.0 f1-7)) (* f5-1 f1-7))) + ) + (+ (* (+ (* f3-5 (- 1.0 f0-4)) (* f1-9 f0-4)) (-> obj y-scale)) (-> obj y-offset)) + ) + ) + +(defun point-in-bbox? ((arg0 bounding-box) (arg1 vector)) + (and (>= (-> arg1 x) (-> arg0 min x)) + (>= (-> arg1 y) (-> arg0 min y)) + (>= (-> arg1 z) (-> arg0 min z)) + (>= (-> arg0 max x) (-> arg1 x)) + (>= (-> arg0 max y) (-> arg1 y)) + (>= (-> arg0 max z) (-> arg1 z)) + ) + ) + +(defmethod debug-draw-mesh xz-height-map ((obj xz-height-map) (arg0 vector)) + (local-vars (sv-80 int) (sv-96 int)) + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (mem-copy! (the-as pointer (-> s5-0 vector 2)) (the-as pointer arg0) 32) + (.svf (&-> (-> s5-0 vector) 0 quad) vf0) + (let ((f30-0 (/ 1.0 (-> obj z-inv-spacing))) + (f28-0 (/ 1.0 (-> obj x-inv-spacing))) + (s4-0 (-> obj x-dim)) + (s3-0 (-> obj z-dim)) + ) + (let ((s2-0 (&-> (-> obj data) 0))) + (set! (-> s5-0 vector 0 z) (-> obj z-offset)) + (countdown (s1-0 s3-0) + (let ((s0-0 s2-0)) + (set! (-> s5-0 vector 0 x) (-> obj x-offset)) + (set! (-> s5-0 vector 0 y) (+ (-> obj y-offset) (* (the float (-> s0-0 0)) (-> obj y-scale)))) + (set! sv-80 (+ s4-0 -1)) + (while (nonzero? sv-80) + (set! sv-80 (+ sv-80 -1)) + (set! (-> s5-0 vector 1 quad) (-> s5-0 vector 0 quad)) + (+! (-> s5-0 vector 0 x) f28-0) + (set! s0-0 (&-> s0-0 1)) + (set! (-> s5-0 vector 0 y) (+ (-> obj y-offset) (* (the float (-> s0-0 0)) (-> obj y-scale)))) + (if (and (point-in-bbox? (the-as bounding-box (-> s5-0 vector 2)) (the-as vector (-> s5-0 vector))) + (point-in-bbox? (the-as bounding-box (-> s5-0 vector 2)) (-> s5-0 vector 1)) + ) + (add-debug-line + #t + (bucket-id debug2) + (the-as vector (-> s5-0 vector)) + (-> s5-0 vector 1) + *color-red* + #f + (the-as rgba -1) + ) + ) + ) + ) + (+! (-> s5-0 vector 0 z) f30-0) + (&+! s2-0 s4-0) + ) + ) + (let ((s2-1 (&-> (-> obj data) 0))) + (set! (-> s5-0 vector 0 x) (-> obj x-offset)) + (countdown (s1-1 s4-0) + (let ((s0-1 (the-as pointer s2-1))) + (set! (-> s5-0 vector 0 z) (-> obj z-offset)) + (set! (-> s5-0 vector 0 y) + (+ (-> obj y-offset) (* (the float (-> (the-as (pointer int8) s0-1) 0)) (-> obj y-scale))) + ) + (set! sv-96 (+ s3-0 -1)) + (while (nonzero? sv-96) + (set! sv-96 (+ sv-96 -1)) + (set! (-> s5-0 vector 1 quad) (-> s5-0 vector 0 quad)) + (+! (-> s5-0 vector 0 z) f30-0) + (&+! s0-1 s4-0) + (set! (-> s5-0 vector 0 y) + (+ (-> obj y-offset) (* (the float (-> (the-as (pointer int8) s0-1))) (-> obj y-scale))) + ) + (if (and (point-in-bbox? (the-as bounding-box (-> s5-0 vector 2)) (the-as vector (-> s5-0 vector))) + (point-in-bbox? (the-as bounding-box (-> s5-0 vector 2)) (-> s5-0 vector 1)) + ) + (add-debug-line + #t + (bucket-id debug2) + (the-as vector (-> s5-0 vector)) + (-> s5-0 vector 1) + *color-blue* + #f + (the-as rgba -1) + ) + ) + ) + ) + (+! (-> s5-0 vector 0 x) f28-0) + (set! s2-1 (&-> s2-1 1)) + ) + ) + ) + ) + 0 + (none) + ) + ) + +(defmethod debug-draw xz-height-map ((obj xz-height-map) (arg0 vector)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 (new 'stack-no-clear 'vector4w-2))) + (let ((a1-1 (-> v1-0 vector))) + (let ((a0-1 arg0)) + (let ((a2-1 -573440.0)) + (.mov vf6 a2-1) + ) + (.lvf vf4 (&-> a0-1 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a1-1 0 quad) vf5) + ) + (let ((a1-2 (-> v1-0 vector 1))) + (let ((a0-2 arg0)) + (let ((a2-3 573440.0)) + (.mov vf6 a2-3) + ) + (.lvf vf4 (&-> a0-2 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a1-2 quad) vf5) + ) + (debug-draw-mesh obj (the-as vector (-> v1-0 vector))) + ) + (debug-draw-at-point obj arg0) + 0 + (none) + ) + ) diff --git a/goal_src/jak2/levels/city/common/metalhead-flitter.gc b/goal_src/jak2/levels/city/common/metalhead-flitter.gc index 010c78fd31..3335fd3ae2 100644 --- a/goal_src/jak2/levels/city/common/metalhead-flitter.gc +++ b/goal_src/jak2/levels/city/common/metalhead-flitter.gc @@ -5,5 +5,33 @@ ;; name in dgo: metalhead-flitter ;; dgos: CWI + +(deftype metalhead-flitter (citizen-enemy) + ((move-angle float :offset-assert 980) + (heading basic :offset-assert 984) + (change-dir-time time-frame :offset-assert 992) + (last-change-dir uint64 :offset-assert 1000) + (off-screen-timer uint64 :offset-assert 1008) + (amb-sound-timer uint64 :offset-assert 1016) + (attack-time time-frame :offset-assert 1024) + (target-pos vector :inline :offset-assert 1040) + (attack-pos vector :inline :offset-assert 1056) + (base-height float :offset-assert 1072) + ) + :method-count-assert 210 + :size-assert #x434 + :flag-assert #xd203c00434 + (:methods + (attack () _type_ :state 203) + (ambush-jumping () _type_ :state 204) + (metalhead-flitter-method-205 () none 205) + (metalhead-flitter-method-206 () none 206) + (metalhead-flitter-method-207 () none 207) + (metalhead-flitter-method-208 () none 208) + (metalhead-flitter-method-209 () none 209) + ) + ) + + ;; DECOMP BEGINS diff --git a/goal_src/jak2/levels/city/common/metalhead-grunt.gc b/goal_src/jak2/levels/city/common/metalhead-grunt.gc index e3b2c75bd6..1a7a6bc913 100644 --- a/goal_src/jak2/levels/city/common/metalhead-grunt.gc +++ b/goal_src/jak2/levels/city/common/metalhead-grunt.gc @@ -5,5 +5,39 @@ ;; name in dgo: metalhead-grunt ;; dgos: CWI +(deftype metalhead-grunt (citizen-enemy) + ((patrol-anim grunt-anim-info :offset-assert 980) + (charge-anim grunt-anim-info :offset-assert 984) + (attack-anim grunt-anim-info :offset-assert 988) + (knocked-anim grunt-anim-info :offset-assert 992) + (yellow-hit-anim grunt-anim-info :offset-assert 996) + (blue-hit-anim grunt-anim-info :offset-assert 1000) + (intro-path basic :offset-assert 1004) + (pad-jh1b23jhb13 uint32 :offset-assert 1008) + (use-charge-anim-index int8 :offset-assert 1012) + (knocked-anim-index int8 :offset-assert 1013) + (jumping-ambush-path-pt int8 :offset-assert 1014) + (grunt-flags uint8 :offset-assert 1015) + (state-timeout2 uint64 :offset-assert 1016) + (next-warn-time time-frame :offset-assert 1024) + (dest vector :inline :offset-assert 1040) + (pad-kj1n23kj1n23 uint32 4 :offset-assert 1056) + ) + :method-count-assert 212 + :size-assert #x430 + :flag-assert #xd403b00430 + (:methods + (attack () _type_ :state 203) + (falling-ambush () _type_ :state 204) + (jumping-ambush () _type_ :state 205) + (jumping-ambush-cont () _type_ :state 206) + (wait-for-focus () _type_ :state 207) + (spin-attack () _type_ :state 208) + (metalhead-grunt-method-209 () none 209) + (metalhead-grunt-method-210 () none 210) + (metalhead-grunt-method-211 () none 211) + ) + ) + ;; DECOMP BEGINS diff --git a/goal_src/jak2/levels/city/common/metalhead-predator.gc b/goal_src/jak2/levels/city/common/metalhead-predator.gc index 89899bc8f1..4b81c851ae 100644 --- a/goal_src/jak2/levels/city/common/metalhead-predator.gc +++ b/goal_src/jak2/levels/city/common/metalhead-predator.gc @@ -5,5 +5,41 @@ ;; name in dgo: metalhead-predator ;; dgos: CWI + +(deftype metalhead-predator-shot (metalhead-shot) + () + :method-count-assert 40 + :size-assert #x1f0 ;; 496 + :flag-assert #x28017001f0 + ) + +(deftype metalhead-predator (citizen-enemy) + ( + (los los-control :inline :offset-assert 992) + (want-stop symbol :offset-assert 1140) + (target-pos vector :inline :offset-assert 1152) + (curr-node int32 :offset-assert 1168) + (hide-pos vector :inline :offset-assert 1184) + (next-change int64 :offset-assert 1200) + (shoot-angle degrees :offset-assert 1208) + (miss-amount float :offset-assert 1212) + (ambient-sound-id uint32 :offset-assert 1216) + (shock-effect-time time-frame :offset-assert 1224) + (shock-effect-end int64 :offset-assert 1232) + (fade float :offset-assert 1240) + (dest-fade float :offset-assert 1244) + ) + :method-count-assert 209 + :size-assert #x4e0 ;; 1248 + :flag-assert #xd1046004e0 + (:methods + (fire () _type_ :state 203) + (close-attack () _type_ :state 204) + (metalhead-predator-method-205 () none 205) + (metalhead-predator-method-206 () none 206) + (metalhead-predator-method-207 () none 207) + (metalhead-predator-method-208 () none 208)) + ) + ;; DECOMP BEGINS diff --git a/goal_src/jak2/levels/city/common/nav-graph-h.gc b/goal_src/jak2/levels/city/common/nav-graph-h.gc index 67de3b8313..14daa8a4ed 100644 --- a/goal_src/jak2/levels/city/common/nav-graph-h.gc +++ b/goal_src/jak2/levels/city/common/nav-graph-h.gc @@ -7,6 +7,27 @@ (declare-type nav-node structure) +(defenum nav-branch-clock-type + :type uint8 + (no-clock 0) + (clock2 1) + (clock3 2) + (clock4 3) + ) + +(defenum nav-branch-clock-mask + :type uint8 + :bitfield #t + (phase-1 0) + (phase-1a 1) + (phase-2 2) + (phase-2a 3) + (phase-3 4) + (phase-3a 5) + (phase-4 6) + (phase-4a 7) + ) + ;; +++nav-node-flag-byte (defenum nav-node-flag-byte "The same as [[nav-node-flag]] but more compact" @@ -22,35 +43,35 @@ ;; DECOMP BEGINS (deftype nav-branch (structure) - ((node int32 2 :offset-assert 0) - (src-node nav-node :offset 0) - (dest-node nav-node :offset 4) - (temp-dest-node-id int32 :offset 4) - (speed-limit uint8 :offset-assert 8) - (density uint8 :offset-assert 9) - (clock-type uint8 :offset-assert 10) - (clock-mask uint8 :offset-assert 11) - (max-user-count uint8 :offset-assert 12) - (user-count uint8 :offset-assert 13) - (width uint8 :offset-assert 14) - (flags uint8 :offset-assert 15) + ((node nav-node 2 :offset-assert 0) + (src-node nav-node :offset 0) + (dest-node nav-node :offset 4) + (temp-dest-node-id int32 :offset 4) + (speed-limit uint8 :offset-assert 8) + (density uint8 :offset-assert 9) + (clock-type nav-branch-clock-type :offset-assert 10) + (clock-mask nav-branch-clock-mask :offset-assert 11) + (max-user-count uint8 :offset-assert 12) + (user-count uint8 :offset-assert 13) + (width uint8 :offset-assert 14) + (flags uint8 :offset-assert 15) ) :method-count-assert 21 :size-assert #x10 :flag-assert #x1500000010 (:methods - (nav-branch-method-9 (_type_) none 9) - (nav-branch-method-10 (_type_ object int) none 10) + (set-default-density-speed-and-width (_type_) none 9) + (debug-print (_type_ object int) none 10) (get-density (_type_) float 11) (get-speed-limit (_type_) float 12) (get-width (_type_) float 13) (user-limit-reached? (_type_) symbol 14) (dest-node-id-at-max? (_type_) symbol 15) - (nav-branch-method-16 (_type_ float) none 16) - (nav-branch-method-17 (_type_ float) none 17) - (nav-branch-method-18 (_type_ float) none 18) - (nav-branch-method-19 (_type_ nav-node) none 19) - (nav-branch-method-20 (_type_ nav-node) none 20) + (set-density (_type_ float) none 16) + (set-speed-limit (_type_ float) none 17) + (set-width (_type_ float) none 18) + (set-src-node (_type_ nav-node) none 19) + (set-dst-node (_type_ nav-node) none 20) ) ) @@ -75,15 +96,15 @@ :size-assert #x20 :flag-assert #x1600000020 (:methods - (nav-node-method-9 (_type_) none 9) - (nav-node-method-10 (_type_ symbol string) none 10) - (nav-node-method-11 (_type_ int) none 11) - (nav-node-method-12 (_type_ vector nav-node) none 12) - (nav-node-method-13 (_type_ vector) none 13) - (nav-node-method-14 (_type_ vector) none 14) - (nav-node-method-15 (_type_ uint) none 15) - (nav-node-method-16 (_type_ float) none 16) - (nav-node-method-17 (_type_ float) none 17) + (debug-draw (_type_) none 9) + (debug-print (_type_ symbol string) none 10) + (remove-branch-by-idx (_type_ int) none 11) + (init-from-pt-and-heading (_type_ vector vector) none 12) + (set-pos-xyz (_type_ vector) none 13) + (set-angle-from-heading (_type_ vector) none 14) + (set-id-and-link-branches-back (_type_ uint) none 15) + (set-radius (_type_ float) none 16) + (set-angle (_type_ float) none 17) (get-position (_type_ vector) vector 18) (calc-sine-and-cosine! (_type_ vector) vector 19) (get-angle (_type_) float 20) @@ -187,42 +208,42 @@ :flag-assert #x2d0000003c (:methods (new (symbol type int int int uint) _type_ 0) - (nav-graph-method-9 (_type_) none 9) + (debug-draw-nodes (_type_) none 9) (nav-graph-method-10 (_type_ vector int) none 10) (nav-graph-method-11 (_type_) none 11) (nav-graph-method-12 (_type_) none 12) (nav-graph-method-13 (_type_ int int) none 13) (nav-graph-method-14 (_type_ int int) none 14) - (nav-graph-method-15 (_type_) none 15) - (nav-graph-method-16 (_type_ int) nav-node 16) - (nav-graph-method-17 (_type_ nav-node) none 17) - (nav-graph-method-18 (_type_ nav-node int) none 18) + (debug-reset (_type_) none 15) + (debug-add-node (_type_ int) nav-node 16) + (debug-link-node-to-graph (_type_ nav-node) none 17) + (debug-reset-branch-array (_type_ nav-node int) none 18) (nav-graph-method-19 (_type_ int int int int int int) none 19) (nav-graph-method-20 (_type_ int int) none 20) - (nav-graph-method-21 (_type_) none 21) - (nav-graph-method-22 (_type_ int int) none 22) - (nav-graph-method-23 (_type_ int int) none 23) - (nav-graph-method-24 (_type_ int int) none 24) - (nav-graph-method-25 (_type_ symbol symbol) none 25) - (nav-graph-method-26 (_type_ symbol symbol) none 26) - (nav-graph-method-27 (_type_ nav-node-flag-byte nav-node-flag-byte symbol) none 27) - (nav-graph-method-28 (_type_) none 28) - (nav-graph-method-29 (_type_ symbol) none 29) - (nav-graph-method-30 (_type_ uint) none 30) - (nav-graph-method-31 (_type_ float) none 31) - (nav-graph-method-32 (_type_ float) none 32) - (nav-graph-method-33 (_type_ float) none 33) - (nav-graph-method-34 (_type_ float) none 34) - (nav-graph-method-35 (_type_ int) none 35) - (nav-graph-method-36 (_type_ int) none 36) - (nav-graph-method-37 (_type_ vector) none 37) + (move-selected-to-height-map-height (_type_) none 21) + (select-nodes-in-range (_type_ int int) none 22) + (deselect-nodes-in-range (_type_ int int) none 23) + (toggle-select-nodes-in-range (_type_ int int) none 24) + (select-nodes-in-level (_type_ symbol symbol) none 25) + (select-nodes-by-nav-mesh-id (_type_ int symbol) none 26) + (select-nodes-by-flags (_type_ nav-node-flag-byte nav-node-flag-byte symbol) none 27) + (print-selected-nodes (_type_) none 28) + (assign-selected-nodes-to-level (_type_ symbol) none 29) + (assign-selected-nodes-to-nav-mesh (_type_ uint) none 30) + (set-radius-of-selected-nodes (_type_ float) none 31) + (set-speed-limit-of-selected (_type_ float) none 32) + (set-density-of-selected (_type_ float) none 33) + (set-width-of-selected (_type_ float) none 34) + (or-flags-of-selected-nodes (_type_ nav-node-flag-byte) none 35) + (and-flags-of-selected-nodes (_type_ nav-node-flag-byte) none 36) + (offset-pos-of-selected (_type_ vector) none 37) (nav-graph-method-38 (_type_) none 38) (nav-graph-method-39 (_type_) none 39) (nav-graph-method-40 (_type_ int) int 40) (node-at-idx (_type_ int) nav-node 41) - (nav-graph-method-42 (_type_) none 42) - (nav-graph-method-43 (_type_ nav-graph-link string) none 43) - (from-editor (_type_ nav-node symbol) none 44) + (patch-nodes (_type_) none 42) + (copy-to-mysql-graph (_type_ mysql-nav-graph string) none 43) + (from-editor (_type_ mysql-nav-graph symbol) none 44) ) ) diff --git a/goal_src/jak2/levels/city/common/nav-graph.gc b/goal_src/jak2/levels/city/common/nav-graph.gc index f9f8b39478..e9ef4b0951 100644 --- a/goal_src/jak2/levels/city/common/nav-graph.gc +++ b/goal_src/jak2/levels/city/common/nav-graph.gc @@ -7,3 +7,1362 @@ ;; DECOMP BEGINS +(defmethod set-density nav-branch ((obj nav-branch) (arg0 float)) + (set! (-> obj density) (the-as uint (max 0 (min 255 (the int (+ 0.5 (* 128.0 arg0))))))) + 0 + (none) + ) + +(defmethod set-speed-limit nav-branch ((obj nav-branch) (arg0 float)) + (set! (-> obj speed-limit) (the-as uint (max 0 (min 255 (the int (+ 0.5 (* 0.0009765625 arg0))))))) + 0 + (none) + ) + +(defmethod set-width nav-branch ((obj nav-branch) (arg0 float)) + (set! (-> obj width) (the-as uint (max 0 (min 255 (the int (+ 0.5 (* 0.00390625 arg0))))))) + 0 + (none) + ) + +(defmethod set-src-node nav-branch ((obj nav-branch) (arg0 nav-node)) + (set! (-> obj src-node) arg0) + 0 + (none) + ) + +(defmethod set-dst-node nav-branch ((obj nav-branch) (arg0 nav-node)) + (set! (-> obj dest-node) arg0) + 0 + (none) + ) + +(defmethod set-default-density-speed-and-width nav-branch ((obj nav-branch)) + (set-density obj 0.25) + (set-speed-limit obj 61440.0) + (set-width obj 16384.0) + 0 + (none) + ) + +(defmethod debug-draw nav-node ((obj nav-node)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'sphere)) + ) + (let ((a1-0 obj) + (v1-0 gp-0) + ) + (set! (-> v1-0 quad) (-> a1-0 position quad)) + (set! (-> v1-0 w) 1.0) + ) + (set! (-> s4-0 quad) (-> gp-0 quad)) + (let ((v1-2 obj)) + (set! (-> s4-0 r) (* 1024.0 (the float (-> v1-2 radius)))) + ) + (when (logtest? (-> obj flags) (nav-node-flag-byte selected)) + (let ((v1-8 (new 'stack-no-clear 'nav-graph-link))) + (let ((a1-3 (&-> v1-8 id))) + (let ((a0-6 gp-0)) + (let ((a2-1 -8192.0)) + (.mov vf6 a2-1) + ) + (.lvf vf4 (&-> a0-6 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (the-as (pointer uint128) (&-> a1-3 0)) vf5) + ) + (let ((a1-4 (-> v1-8 dummy-node))) + (let ((a0-7 gp-0)) + (let ((a2-3 8192.0)) + (.mov vf6 a2-3) + ) + (.lvf vf4 (&-> a0-7 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a1-4 position quad) vf5) + ) + (add-debug-box + #t + (bucket-id debug2) + (the-as vector (&-> v1-8 id)) + (the-as vector (-> v1-8 dummy-node)) + *color-yellow* + ) + ) + ) + (when (and (not (logtest? (-> obj flags) (nav-node-flag-byte hidden))) + (let ((f0-6 (vector-vector-distance-squared gp-0 (camera-pos))) + (f1-2 327680.0) + ) + (and (< f0-6 (* f1-2 f1-2)) (sphere-in-view-frustum? s4-0)) + ) + ) + (add-debug-x #t (bucket-id debug2) gp-0 *color-red*) + (let ((s4-1 add-debug-text-3d) + (s3-1 #t) + (s2-1 324) + ) + (format (clear *temp-string*) "~D ~D" (-> obj id) (-> obj nav-mesh-id)) + (s4-1 + s3-1 + (the-as bucket-id s2-1) + *temp-string* + gp-0 + (if (logtest? (-> obj flags) (nav-node-flag-byte blocked)) + (font-color precursor-#ec3b00) + (font-color cyan-#00fefe) + ) + (the-as vector2h #f) + ) + ) + (let ((s4-2 add-debug-vector) + (s3-2 #t) + (s2-2 324) + (s1-1 (new 'stack-no-clear 'vector)) + ) + (let ((f0-8 (the float (-> obj angle))) + (s5-1 (new 'stack-no-clear 'vector)) + ) + (sincos! s5-1 f0-8) + (set! (-> s1-1 x) (-> s5-1 y)) + (set! (-> s1-1 y) 0.0) + (set! (-> s1-1 z) (- (-> s5-1 x))) + ) + (set! (-> s1-1 w) 1.0) + (s4-2 s3-2 (the-as bucket-id s2-2) gp-0 s1-1 (meters 2) *color-green*) + ) + ) + ) + 0 + (none) + ) + ) + +(defmethod debug-print nav-branch ((obj nav-branch) (arg0 object) (arg1 int)) + (format arg0 "~S~T~T~T (new-nav-branch :dest-node-id ~d~%" arg1 (-> obj dest-node id)) + (let ((t9-1 format) + (a0-2 arg0) + (a1-2 "~S~T~T~T~T~T :density ~4,,3f~%") + (a2-2 arg1) + (v1-1 obj) + ) + (t9-1 a0-2 a1-2 a2-2 (* 0.0078125 (the float (-> v1-1 density)))) + ) + (let ((t9-2 format) + (a0-3 arg0) + (a1-3 "~S~T~T~T~T~T :width ~4,,3M~%") + (a2-3 arg1) + (v1-3 obj) + ) + (t9-2 a0-3 a1-3 a2-3 (* 256.0 (the float (-> v1-3 width)))) + ) + (let ((t9-3 format) + (a0-4 arg0) + (a1-4 "~S~T~T~T~T~T :speed-limit ~4,,3M~%") + (a2-4 arg1) + (v1-5 obj) + ) + (t9-3 a0-4 a1-4 a2-4 (* 1024.0 (the float (-> v1-5 speed-limit)))) + ) + (when (nonzero? (-> obj clock-type)) + (let ((t9-4 format) + (a0-5 arg0) + (a1-5 "~S~T~T~T~T~T :clock-type ~S~%") + (a2-5 arg1) + (v1-9 (-> obj clock-type)) + ) + (t9-4 a0-5 a1-5 a2-5 (cond + ((= v1-9 (nav-branch-clock-type clock3)) + "clock3" + ) + ((= v1-9 (nav-branch-clock-type no-clock)) + "no-clock" + ) + ((= v1-9 (nav-branch-clock-type clock2)) + "clock2" + ) + ((= v1-9 (nav-branch-clock-type clock4)) + "clock4" + ) + (else + "*unknown*" + ) + ) + ) + ) + (format arg0 "~S~T~T~T~T~T :clock-mask (" arg1) + (let ((s4-1 (-> obj clock-mask))) + (if (= (logand s4-1 (nav-branch-clock-mask phase-1a)) (nav-branch-clock-mask phase-1a)) + (format arg0 "phase-1a ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-2a)) (nav-branch-clock-mask phase-2a)) + (format arg0 "phase-2a ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-1)) (nav-branch-clock-mask phase-1)) + (format arg0 "phase-1 ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-3a)) (nav-branch-clock-mask phase-3a)) + (format arg0 "phase-3a ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-2)) (nav-branch-clock-mask phase-2)) + (format arg0 "phase-2 ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-4a)) (nav-branch-clock-mask phase-4a)) + (format arg0 "phase-4a ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-3)) (nav-branch-clock-mask phase-3)) + (format arg0 "phase-3 ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-4)) (nav-branch-clock-mask phase-4)) + (format arg0 "phase-4 ") + ) + ) + (format arg0 ")~%") + ) + (format arg0 "~S~T~T~T~T~T )~%" arg1) + 0 + (none) + ) + +(defmethod debug-print nav-node ((obj nav-node) (arg0 symbol) (arg1 string)) + (format arg0 "~S (new-nav-node :id ~d~%" arg1 (-> obj id)) + (format arg0 "~S~T :branch-list (~%" arg1) + (dotimes (s3-0 (-> obj branch-count)) + (debug-print (-> obj branch-array s3-0) arg0 (the-as int arg1)) + ) + (format arg0 "~S~T~T~T )~%" arg1) + (let* ((v1-6 (-> obj flags)) + (s3-1 (logclear v1-6 (nav-node-flag-byte visited blocked))) + ) + (when (nonzero? s3-1) + (format arg0 "~S~T :flags (" arg1) + (if (= (logand s3-1 (nav-node-flag-byte blocked)) (nav-node-flag-byte blocked)) + (format arg0 "blocked ") + ) + (if (= (logand s3-1 (nav-node-flag-byte selected)) (nav-node-flag-byte selected)) + (format arg0 "selected ") + ) + (if (= (logand s3-1 (nav-node-flag-byte pedestrian)) (nav-node-flag-byte pedestrian)) + (format arg0 "pedestrian ") + ) + (if (= (logand s3-1 (nav-node-flag-byte visited)) (nav-node-flag-byte visited)) + (format arg0 "visited ") + ) + (if (= (logand s3-1 (nav-node-flag-byte hidden)) (nav-node-flag-byte hidden)) + (format arg0 "hidden ") + ) + (format arg0 ")~%") + ) + ) + (let ((v1-24 (new 'stack-no-clear 'vector))) + (let ((a2-6 obj) + (a0-19 v1-24) + ) + (set! (-> a0-19 quad) (-> a2-6 position quad)) + (set! (-> a0-19 w) 1.0) + ) + (format arg0 "~S~T :position (~4,,2M ~4,,2M ~4,,2M)~%" arg1 (-> v1-24 x) (-> v1-24 y) (-> v1-24 z)) + ) + (format arg0 "~S~T :angle ~4,,3f~%" arg1 (* 0.005493164 (the float (-> obj angle)))) + (let ((t9-13 format) + (a0-22 arg0) + (a1-16 "~S~T :radius ~4,,2M~%") + (a2-11 arg1) + (v1-30 obj) + ) + (t9-13 a0-22 a1-16 a2-11 (* 1024.0 (the float (-> v1-30 radius)))) + ) + (if (nonzero? (-> obj nav-mesh-id)) + (format arg0 "~S~T :nav-mesh-id ~d~%" arg1 (-> obj nav-mesh-id)) + ) + (if (-> obj level) + (format arg0 "~S~T :level ~s~%" arg1 (-> obj level)) + ) + (format arg0 "~S~T )~%" arg1) + 0 + (none) + ) + +(defmethod set-pos-xyz nav-node ((obj nav-node) (arg0 vector)) + (let ((f0-0 (-> obj position w))) + (set! (-> obj position quad) (-> arg0 quad)) + (set! (-> obj position w) f0-0) + ) + 0 + (none) + ) + +(defmethod set-angle-from-heading nav-node ((obj nav-node) (arg0 vector)) + (set! (-> obj angle) (the-as uint (the int (atan (- (-> arg0 z)) (-> arg0 x))))) + 0 + (none) + ) + +(defmethod set-radius nav-node ((obj nav-node) (arg0 float)) + (set! (-> obj radius) (the-as uint (max 0 (min 255 (the int (+ 0.5 (* 0.0009765625 arg0))))))) + 0 + (none) + ) + +(defmethod set-angle nav-node ((obj nav-node) (arg0 float)) + (set! (-> obj angle) (the-as uint (the int (+ 0.5 arg0)))) + 0 + (none) + ) + +(defmethod set-id-and-link-branches-back nav-node ((obj nav-node) (arg0 uint)) + (set! (-> obj id) arg0) + (dotimes (v1-0 (-> obj branch-count)) + (set! (-> obj branch-array v1-0 src-node) obj) + ) + 0 + (none) + ) + +(defmethod init-from-pt-and-heading nav-node ((obj nav-node) (arg0 vector) (arg1 vector)) + (set-pos-xyz obj arg0) + (set-angle-from-heading obj arg1) + (set! (-> obj flags) (nav-node-flag-byte pedestrian selected)) + (set-radius obj 32768.0) + (set! (-> obj level) 'ctyport) + (set! (-> obj nav-mesh-id) (the-as uint 0)) + (dotimes (s5-1 (-> obj branch-count)) + (set-default-density-speed-and-width (-> obj branch-array s5-1)) + ) + 0 + (none) + ) + +(defmethod remove-branch-by-idx nav-node ((obj nav-node) (arg0 int)) + (when (and (>= arg0 0) (< arg0 (-> obj branch-count))) + (let ((s5-0 (+ arg0 1)) + (s4-0 arg0) + ) + (while (< s5-0 (-> obj branch-count)) + (mem-copy! (the-as pointer (-> obj branch-array s4-0)) (the-as pointer (-> obj branch-array s5-0)) 16) + (+! s5-0 1) + (+! s4-0 1) + ) + ) + (+! (-> obj branch-count) -1) + ) + 0 + (none) + ) + +(defmethod debug-reset-branch-array nav-graph ((obj nav-graph) (arg0 nav-node) (arg1 int)) + "kinda dangerous" + (set! (-> arg0 branch-array) (the-as (inline-array nav-branch) (-> obj branch-array (-> obj branch-count)))) + (set! (-> arg0 branch-count) arg1) + (+! (-> obj branch-count) arg1) + (dotimes (s4-0 arg1) + (let ((s3-0 (-> arg0 branch-array s4-0))) + (set-default-density-speed-and-width s3-0) + (set! (-> s3-0 src-node) arg0) + (set! (-> s3-0 dest-node) #f) + ) + ) + 0 + (none) + ) + +(defmethod debug-add-node nav-graph ((obj nav-graph) (arg0 int)) + (let ((s4-0 (the-as nav-node #f))) + (let ((s5-0 (-> obj node-count)) + (v1-1 (+ arg0 -1 (-> obj branch-count))) + ) + (when (and (< s5-0 2000) (< v1-1 2500)) + (set! s4-0 (-> obj node-array s5-0)) + (debug-reset-branch-array obj s4-0 arg0) + (set-id-and-link-branches-back s4-0 (the-as uint s5-0)) + (+! (-> obj node-count) 1) + ) + ) + s4-0 + ) + ) + +(defmethod debug-link-node-to-graph nav-graph ((obj nav-graph) (arg0 nav-node)) + (when (> (-> arg0 branch-count) 0) + (let ((a0-1 (-> arg0 branch-array 0)) + (t9-0 (method-of-type nav-branch set-dst-node)) + (a2-0 obj) + (v1-4 (-> obj first-node)) + (a1-1 (the-as nav-node #f)) + ) + (if (and (>= v1-4 0) (< v1-4 (-> a2-0 node-count))) + (set! a1-1 (-> a2-0 node-array v1-4)) + ) + (t9-0 a0-1 a1-1) + ) + (let ((v1-9 (+ (-> arg0 id) -1))) + (when (>= v1-9 (the-as uint (-> obj first-node))) + (let ((v1-11 (-> obj node-array v1-9))) + (set! (-> v1-11 branch-count) 1) + (set-dst-node (-> v1-11 branch-array 0) arg0) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod nav-graph-method-13 nav-graph ((obj nav-graph) (arg0 int) (arg1 int)) + (when (and (< arg0 (-> obj node-count)) (> arg1 0)) + (let ((s4-1 (min arg1 (- (-> obj node-count) arg0)))) + (dotimes (s3-0 (-> obj node-count)) + (let ((s2-0 (-> obj node-array s3-0))) + (dotimes (s1-0 (-> s2-0 branch-count)) + (let ((v1-9 (nav-graph-method-40 obj (the-as int (-> s2-0 branch-array s1-0 dest-node))))) + (when (and (>= v1-9 arg0) (< v1-9 (+ arg0 s4-1))) + (let ((v1-11 (-> obj node-array v1-9))) + (cond + ((= (-> v1-11 branch-count) 1) + (let ((v1-14 (-> v1-11 branch-array 0 dest-node id))) + (if (or (< v1-14 (the-as uint arg0)) (>= v1-14 (the-as uint (+ arg0 s4-1)))) + (set-dst-node (-> s2-0 branch-array s1-0) (-> obj node-array v1-14)) + (remove-branch-by-idx s2-0 s1-0) + ) + ) + ) + (else + (remove-branch-by-idx s2-0 s1-0) + ) + ) + ) + ) + ) + ) + ) + ) + (dotimes (s3-1 (-> obj node-count)) + (let ((s2-1 (-> obj node-array s3-1))) + (dotimes (s1-1 (-> s2-1 branch-count)) + (let ((v1-28 (nav-graph-method-40 obj (the-as int (-> s2-1 branch-array s1-1 dest-node))))) + (if (>= v1-28 (+ arg0 s4-1)) + (set-dst-node (-> s2-1 branch-array s1-1) (-> obj node-array (- v1-28 s4-1))) + ) + ) + ) + ) + ) + (let ((s3-2 arg0) + (s2-2 (-> obj node-array (+ arg0 s4-1))) + (s1-2 (-> obj node-array arg0)) + ) + (countdown (s0-0 (- (-> obj node-count) (+ arg0 s4-1))) + (mem-copy! (the-as pointer s1-2) (the-as pointer s2-2) 32) + (set-id-and-link-branches-back s1-2 (the-as uint s3-2)) + (&+! s2-2 32) + (&+! s1-2 32) + (+! s3-2 1) + ) + ) + (set! (-> obj node-count) (- (-> obj node-count) s4-1)) + (if (< arg0 (-> obj first-node)) + (set! (-> obj first-node) (- (-> obj first-node) s4-1)) + ) + ) + ) + 0 + (none) + ) + +(defmethod nav-graph-method-14 nav-graph ((obj nav-graph) (arg0 int) (arg1 int)) + (when (and (< arg0 (-> obj node-count)) (> arg1 0)) + (dotimes (s3-0 (-> obj node-count)) + (let ((s2-0 (-> obj node-array s3-0))) + (dotimes (s1-0 (-> s2-0 branch-count)) + (let ((v1-7 (nav-graph-method-40 obj (the-as int (-> s2-0 branch-array s1-0 dest-node))))) + (if (< arg0 v1-7) + (set-dst-node (-> s2-0 branch-array s1-0) (-> obj node-array (+ v1-7 arg1))) + ) + ) + ) + ) + ) + (let* ((s3-1 (+ arg1 -1 (-> obj node-count))) + (s2-1 (-> obj node-array (- s3-1 arg1))) + (s1-1 (-> obj node-array s3-1)) + ) + (countdown (s0-0 (- (-> obj node-count) arg0)) + (mem-copy! (the-as pointer s1-1) (the-as pointer s2-1) 32) + (set-id-and-link-branches-back s1-1 (the-as uint s3-1)) + (set! s2-1 (&+ s2-1 -32)) + (set! s1-1 (&+ s1-1 -32)) + (+! s3-1 -1) + ) + ) + (+! (-> obj node-count) arg1) + (+! (-> obj first-node) arg1) + (let ((s3-2 (-> obj node-array arg0)) + (s2-2 (-> obj node-array arg0)) + ) + (dotimes (s1-2 arg1) + (mem-copy! (the-as pointer s2-2) (the-as pointer s3-2) 32) + (set-id-and-link-branches-back s2-2 (the-as uint arg0)) + (+! (-> s2-2 position y) (* 8192.0 (the float (+ s1-2 1)))) + (debug-reset-branch-array obj s2-2 1) + (set-dst-node (-> s2-2 branch-array 0) (-> obj node-array (+ arg0 1))) + (&+! s2-2 32) + (+! arg0 1) + ) + ) + ) + 0 + (none) + ) + +(defmethod debug-reset nav-graph ((obj nav-graph)) + (set! (-> obj node-count) 0) + (set! (-> obj branch-count) 0) + (set! (-> obj first-node) 0) + (set! (-> obj patched) #f) + 0 + (none) + ) + +(defmethod nav-graph-method-12 nav-graph ((obj nav-graph)) + (set! (-> obj first-node) (-> obj node-count)) + 0 + (none) + ) + +(defmethod print-selected-nodes nav-graph ((obj nav-graph)) + (let ((s4-0 0) + (s1-0 0) + (v1-0 #f) + (s3-0 0) + (gp-0 0) + ) + (dotimes (s2-0 (-> obj node-count)) + (let* ((a0-2 (-> obj node-array s2-0)) + (s0-1 (logtest? (-> a0-2 flags) (nav-node-flag-byte selected))) + ) + (when s0-1 + (+! gp-0 1) + (if (not v1-0) + (set! s4-0 s2-0) + ) + (set! s1-0 s2-0) + ) + (set! v1-0 (and (not s0-1) v1-0)) + (when (or v1-0 (and s0-1 (= s2-0 (+ (-> obj node-count) -1)))) + (if (> s3-0 0) + (format #t ", ") + ) + (if (= s4-0 s1-0) + (format #t "~d" s4-0) + (format #t "~d-~d" s4-0 s1-0) + ) + (+! s3-0 1) + ) + (set! v1-0 s0-1) + ) + ) + (format #t "~%") + (format #t "~d nodes selected~%" gp-0) + ) + 0 + (none) + ) + +(defmethod select-nodes-in-range nav-graph ((obj nav-graph) (arg0 int) (arg1 int)) + (when (< arg0 (-> obj node-count)) + (let ((v1-3 (min arg1 (+ (-> obj node-count) -1))) + (a2-3 arg0) + ) + (+ (- 1 arg0) v1-3) + (while (>= v1-3 a2-3) + (let ((a1-4 (-> obj node-array a2-3))) + (logior! (-> a1-4 flags) (nav-node-flag-byte selected)) + ) + (+! a2-3 1) + ) + ) + ) + (print-selected-nodes obj) + 0 + (none) + ) + +(defmethod deselect-nodes-in-range nav-graph ((obj nav-graph) (arg0 int) (arg1 int)) + (when (< arg0 (-> obj node-count)) + (let ((v1-3 (min arg1 (+ (-> obj node-count) -1))) + (a2-3 arg0) + ) + (+ (- 1 arg0) v1-3) + (while (>= v1-3 a2-3) + (let ((a1-4 (-> obj node-array a2-3))) + (logclear! (-> a1-4 flags) (nav-node-flag-byte selected)) + ) + (+! a2-3 1) + ) + ) + ) + (print-selected-nodes obj) + 0 + (none) + ) + +(defmethod toggle-select-nodes-in-range nav-graph ((obj nav-graph) (arg0 int) (arg1 int)) + (when (< arg0 (-> obj node-count)) + (let ((v1-3 (min arg1 (+ (-> obj node-count) -1))) + (a2-3 arg0) + ) + (+ (- 1 arg0) v1-3) + (while (>= v1-3 a2-3) + (let ((a1-4 (-> obj node-array a2-3))) + (logxor! (-> a1-4 flags) (nav-node-flag-byte selected)) + ) + (+! a2-3 1) + ) + ) + ) + (print-selected-nodes obj) + 0 + (none) + ) + +(defmethod select-nodes-in-level nav-graph ((obj nav-graph) (arg0 symbol) (arg1 symbol)) + (dotimes (v1-0 (-> obj node-count)) + (let* ((a3-1 (-> obj node-array v1-0)) + (t0-2 (= (-> a3-1 level) arg0)) + ) + (case arg1 + (('set) + (logclear! (-> a3-1 flags) (nav-node-flag-byte selected)) + (if t0-2 + (logior! (-> a3-1 flags) (nav-node-flag-byte selected)) + ) + ) + (('and) + (if (not t0-2) + (logclear! (-> a3-1 flags) (nav-node-flag-byte selected)) + ) + ) + (('or) + (if t0-2 + (logior! (-> a3-1 flags) (nav-node-flag-byte selected)) + ) + ) + ) + ) + ) + (print-selected-nodes obj) + 0 + (none) + ) + +(defmethod select-nodes-by-nav-mesh-id nav-graph ((obj nav-graph) (arg0 int) (arg1 symbol)) + (dotimes (v1-0 (-> obj node-count)) + (let* ((a3-1 (-> obj node-array v1-0)) + (t0-2 (= (-> a3-1 nav-mesh-id) arg0)) + ) + (case arg1 + (('set) + (logclear! (-> a3-1 flags) (nav-node-flag-byte selected)) + (if t0-2 + (logior! (-> a3-1 flags) (nav-node-flag-byte selected)) + ) + ) + (('and) + (if (not t0-2) + (logclear! (-> a3-1 flags) (nav-node-flag-byte selected)) + ) + ) + (('or) + (if t0-2 + (logior! (-> a3-1 flags) (nav-node-flag-byte selected)) + ) + ) + ) + ) + ) + (print-selected-nodes obj) + 0 + (none) + ) + +(defmethod select-nodes-by-flags nav-graph ((obj nav-graph) (arg0 nav-node-flag-byte) (arg1 nav-node-flag-byte) (arg2 symbol)) + (dotimes (v1-0 (-> obj node-count)) + (let* ((t0-1 (-> obj node-array v1-0)) + (t1-3 (= (logand (-> t0-1 flags) arg1) arg0)) + ) + (case arg2 + (('set) + (logclear! (-> t0-1 flags) (nav-node-flag-byte selected)) + (if t1-3 + (logior! (-> t0-1 flags) (nav-node-flag-byte selected)) + ) + ) + (('and) + (if (not t1-3) + (logclear! (-> t0-1 flags) (nav-node-flag-byte selected)) + ) + ) + (('or) + (if t1-3 + (logior! (-> t0-1 flags) (nav-node-flag-byte selected)) + ) + ) + ) + ) + ) + (print-selected-nodes obj) + 0 + (none) + ) + +(defmethod assign-selected-nodes-to-level nav-graph ((obj nav-graph) (arg0 symbol)) + (dotimes (v1-0 (-> obj node-count)) + (let ((a2-1 (-> obj node-array v1-0))) + (if (logtest? (-> a2-1 flags) (nav-node-flag-byte selected)) + (set! (-> a2-1 level) arg0) + ) + ) + ) + 0 + (none) + ) + +(defmethod assign-selected-nodes-to-nav-mesh nav-graph ((obj nav-graph) (arg0 uint)) + (dotimes (v1-0 (-> obj node-count)) + (let ((a2-1 (-> obj node-array v1-0))) + (if (logtest? (-> a2-1 flags) (nav-node-flag-byte selected)) + (set! (-> a2-1 nav-mesh-id) arg0) + ) + ) + ) + 0 + (none) + ) + +(defmethod set-radius-of-selected-nodes nav-graph ((obj nav-graph) (arg0 float)) + (dotimes (s4-0 (-> obj node-count)) + (let ((a0-2 (-> obj node-array s4-0))) + (if (logtest? (-> a0-2 flags) (nav-node-flag-byte selected)) + (set-radius a0-2 arg0) + ) + ) + ) + 0 + (none) + ) + +(defmethod or-flags-of-selected-nodes nav-graph ((obj nav-graph) (arg0 nav-node-flag-byte)) + (dotimes (v1-0 (-> obj node-count)) + (let ((a2-1 (-> obj node-array v1-0))) + (if (logtest? (-> a2-1 flags) (nav-node-flag-byte selected)) + (logior! (-> a2-1 flags) arg0) + ) + ) + ) + 0 + (none) + ) + +(defmethod and-flags-of-selected-nodes nav-graph ((obj nav-graph) (arg0 nav-node-flag-byte)) + (let ((v1-0 (lognot arg0))) + (dotimes (a1-1 (-> obj node-count)) + (let ((a2-1 (-> obj node-array a1-1))) + (if (logtest? (-> a2-1 flags) (nav-node-flag-byte selected)) + (logand! (-> a2-1 flags) v1-0) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod set-speed-limit-of-selected nav-graph ((obj nav-graph) (arg0 float)) + (dotimes (s4-0 (-> obj node-count)) + (let ((s3-0 (-> obj node-array s4-0))) + (when (logtest? (-> s3-0 flags) (nav-node-flag-byte selected)) + (dotimes (s2-0 (-> s3-0 branch-count)) + (set-speed-limit (-> s3-0 branch-array s2-0) arg0) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod set-density-of-selected nav-graph ((obj nav-graph) (arg0 float)) + (dotimes (s4-0 (-> obj node-count)) + (let ((s3-0 (-> obj node-array s4-0))) + (when (logtest? (-> s3-0 flags) (nav-node-flag-byte selected)) + (dotimes (s2-0 (-> s3-0 branch-count)) + (set-density (-> s3-0 branch-array s2-0) arg0) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod set-width-of-selected nav-graph ((obj nav-graph) (arg0 float)) + (dotimes (s4-0 (-> obj node-count)) + (let ((s3-0 (-> obj node-array s4-0))) + (when (logtest? (-> s3-0 flags) (nav-node-flag-byte selected)) + (dotimes (s2-0 (-> s3-0 branch-count)) + (set-width (-> s3-0 branch-array s2-0) arg0) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod offset-pos-of-selected nav-graph ((obj nav-graph) (arg0 vector)) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (dotimes (s3-0 (-> obj node-count)) + (let ((a0-2 (-> obj node-array s3-0))) + (when (logtest? (-> a0-2 flags) (nav-node-flag-byte selected)) + (let ((a2-0 a0-2) + (v1-4 s4-0) + ) + (set! (-> v1-4 quad) (-> a2-0 position quad)) + (set! (-> v1-4 w) 1.0) + ) + (vector+! s4-0 s4-0 arg0) + (set-pos-xyz a0-2 s4-0) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod nav-graph-method-38 nav-graph ((obj nav-graph)) + (let ((s5-0 (new 'stack-no-clear 'vehicle-controller)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (dotimes (s3-0 (-> obj node-count)) + (let ((s2-0 (-> obj node-array s3-0))) + (when (and (logtest? (-> s2-0 flags) (nav-node-flag-byte selected)) (= (-> s2-0 branch-count) 1)) + (let ((a1-0 (-> s2-0 branch-array 0))) + (-> a1-0 dest-node) + (vehicle-controller-method-13 s5-0 a1-0 (-> s2-0 position)) + ) + (vehicle-controller-method-11 s5-0) + (vector-! s4-0 (-> s5-0 target-point) (-> s2-0 position)) + (set! (-> s4-0 y) 0.0) + (vector-normalize! s4-0 1.0) + (set-angle-from-heading s2-0 s4-0) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod debug-draw-nodes nav-graph ((obj nav-graph)) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (dotimes (s4-0 (-> obj node-count)) + (let ((s3-0 (-> obj node-array s4-0))) + (when (not (logtest? (-> s3-0 flags) (nav-node-flag-byte hidden))) + (debug-draw s3-0) + (let ((a1-0 s3-0) + (v1-6 (-> s5-0 vector)) + ) + (set! (-> v1-6 0 quad) (-> a1-0 position quad)) + (set! (-> v1-6 0 w) 1.0) + ) + (dotimes (s2-0 (-> s3-0 branch-count)) + (let ((v1-9 (-> s3-0 branch-array s2-0 dest-node))) + (when v1-9 + (let ((a2-0 v1-9) + (a0-7 (-> s5-0 vector 1)) + ) + (set! (-> a0-7 quad) (-> a2-0 position quad)) + (set! (-> a0-7 w) 1.0) + ) + (vector-! (-> s5-0 vector 2) (-> s5-0 vector 1) (the-as vector (-> s5-0 vector))) + (let* ((f0-2 (vector-length (-> s5-0 vector 2))) + (f1-2 (fmax (* 0.75 f0-2) (+ -8192.0 f0-2))) + ) + (vector-float*! (-> s5-0 vector 2) (-> s5-0 vector 2) (/ f1-2 f0-2)) + ) + (vector+! (-> s5-0 trans) (the-as vector (-> s5-0 vector)) (-> s5-0 vector 2)) + (add-debug-line + #t + (bucket-id debug2) + (the-as vector (-> s5-0 vector)) + (-> s5-0 trans) + (cond + ((= (-> v1-9 id) #xffff) + *color-dark-blue* + ) + ((logtest? (-> s3-0 flags) (nav-node-flag-byte pedestrian)) + *color-dark-red* + ) + (else + *color-dark-green* + ) + ) + #f + *color-white* + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch nav-node vs none. +(defmethod nav-graph-method-10 nav-graph ((obj nav-graph) (arg0 vector) (arg1 int)) + (let* ((gp-0 (the-as nav-node #f)) + (f0-0 409600000.0) + (f30-0 (* f0-0 f0-0)) + ) + (dotimes (s2-0 (-> obj node-count)) + (let ((s1-0 (-> obj node-array s2-0)) + (a1-1 (new 'stack-no-clear 'vector)) + ) + (when (and (not (logtest? (-> s1-0 flags) (nav-node-flag-byte hidden))) + (or (not arg1) (and arg1 (logtest? (-> s1-0 flags) (nav-node-flag-byte selected)))) + ) + (let ((a2-1 s1-0) + (v1-8 a1-1) + ) + (set! (-> v1-8 quad) (-> a2-1 position quad)) + (set! (-> v1-8 w) 1.0) + ) + (let ((f0-3 (vector-vector-distance-squared arg0 a1-1))) + (when (< f0-3 f30-0) + (set! gp-0 s1-0) + (set! f30-0 f0-3) + ) + ) + ) + ) + ) + ) + (none) + ) + +(defmethod move-selected-to-height-map-height nav-graph ((obj nav-graph)) + (dotimes (s5-0 (-> obj node-count)) + (let ((s4-0 (-> obj node-array s5-0)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (when (and (not (logtest? (-> s4-0 flags) (nav-node-flag-byte hidden))) + (not (logtest? (-> s4-0 flags) (nav-node-flag-byte pedestrian))) + (logtest? (-> s4-0 flags) (nav-node-flag-byte selected)) + ) + (let ((a1-0 s4-0) + (v1-8 s3-0) + ) + (set! (-> v1-8 quad) (-> a1-0 position quad)) + (set! (-> v1-8 w) 1.0) + ) + (let ((a1-3 s3-0)) + (set! (-> s3-0 y) (get-height-at-point *traffic-height-map* a1-3)) + ) + (set-pos-xyz s4-0 s3-0) + ) + ) + ) + 0 + (none) + ) + +(defmethod nav-graph-method-39 nav-graph ((obj nav-graph)) + (local-vars (sv-80 entity-nav-mesh) (sv-96 entity-nav-mesh)) + (dotimes (s5-0 (-> obj node-count)) + (let ((s4-0 (-> obj node-array s5-0)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (let ((a1-0 s4-0) + (v1-1 s3-0) + ) + (set! (-> v1-1 quad) (-> a1-0 position quad)) + (set! (-> v1-1 w) 1.0) + ) + (when (logtest? (-> s4-0 flags) (nav-node-flag-byte pedestrian)) + (dotimes (s2-0 (-> *level* length)) + (let ((v1-8 (-> *level* level s2-0))) + (when (= (-> v1-8 status) 'active) + (let ((s1-0 (-> v1-8 bsp nav-meshes))) + (when (nonzero? s1-0) + (dotimes (s0-0 (-> s1-0 length)) + (set! sv-80 (-> s1-0 s0-0)) + (-> sv-80 aid) + (set! sv-96 sv-80) + (let ((v1-16 (if (type? sv-96 entity-nav-mesh) + sv-96 + ) + ) + ) + (when v1-16 + (let ((a0-10 (-> v1-16 nav-mesh)) + (a1-5 (new 'stack-no-clear 'nav-find-poly-parms)) + ) + (vector-! (-> a1-5 point) s3-0 (-> a0-10 bounds)) + (set! (-> a1-5 y-threshold) 40960.0) + (set! (-> a1-5 ignore) (the-as uint 2)) + (if (find-poly-containing-point-local a0-10 a1-5) + (set! (-> s4-0 nav-mesh-id) (-> sv-80 aid)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod nav-graph-method-19 nav-graph ((obj nav-graph) (arg0 int) (arg1 int) (arg2 int) (arg3 int) (arg4 int) (arg5 int)) + (let ((gp-0 (-> obj node-array arg0)) + (s0-0 (-> obj node-array arg1)) + (s4-0 (-> obj node-array arg2)) + (s2-0 (-> obj node-array arg3)) + (s1-0 (-> obj node-array arg4)) + (s3-0 (-> obj node-array arg5)) + ) + (debug-reset-branch-array obj s0-0 2) + (set-dst-node (-> s0-0 branch-array 0) s4-0) + (set-dst-node (-> s0-0 branch-array 1) s1-0) + (debug-reset-branch-array obj s2-0 2) + (set-dst-node (-> s2-0 branch-array 0) s1-0) + (set-dst-node (-> s2-0 branch-array 1) gp-0) + (debug-reset-branch-array obj s3-0 2) + (set-dst-node (-> s3-0 branch-array 0) gp-0) + (set-dst-node (-> s3-0 branch-array 1) s4-0) + ) + (none) + ) + +(defmethod nav-graph-method-40 nav-graph ((obj nav-graph) (arg0 int)) + -1 + (shr (- arg0 (the-as int (-> obj node-array 0))) 5) + ) + +(defmethod nav-graph-method-20 nav-graph ((obj nav-graph) (arg0 int) (arg1 int)) + (let ((gp-0 (-> obj node-array arg0)) + (s5-0 (-> obj node-array arg1)) + ) + (debug-reset-branch-array obj gp-0 1) + (set-dst-node (-> gp-0 branch-array 0) s5-0) + ) + (none) + ) + +(defmethod nav-graph-method-11 nav-graph ((obj nav-graph)) + (format #t "(define *traffic-nav-graph*~%") + (format #t " (new-nav-graph~%") + (format #t " :node-list (~%") + (dotimes (s5-0 (-> obj node-count)) + (let ((a0-5 (-> obj node-array s5-0))) + (set! (-> a0-5 id) (the-as uint s5-0)) + (debug-print a0-5 #t " ") + ) + ) + (format #t "~T~T )~%") + (format #t " )~%") + (format #t " )~%") + 0 + (none) + ) + +(defmethod patch-nodes nav-graph ((obj nav-graph)) + "Patch nodes. Node pointers are stored as indices into arrays to be allocated on the level heap +and patched at runtime after loading." + (when (not (-> obj patched)) + (set! (-> obj patched) #t) + (let ((s5-0 0)) + (dotimes (s4-0 (-> obj node-count)) + (let ((s3-0 (-> obj node-array s4-0))) + (dotimes (s2-0 (-> s3-0 branch-count)) + (let ((s1-0 (-> s3-0 branch-array s2-0))) + (+! s5-0 1) + (set-src-node s1-0 s3-0) + (let ((v1-7 (the-as object (-> s1-0 dest-node)))) + (set-dst-node s1-0 (-> obj node-array (the-as uint v1-7))) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; WARN: Function (method 43 nav-graph) has a return type of none, but the expression builder found a return statement. +(defmethod copy-to-mysql-graph nav-graph ((obj nav-graph) (arg0 mysql-nav-graph) (arg1 string)) + (set! (-> arg0 node-array length) 0) + (set! (-> arg0 edge-array length) 0) + (set! (-> arg0 visnode-array length) 0) + (let ((s3-0 (clear *temp-string*))) + (format s3-0 "select nav_graph_id from nav_graph where name='~S'" arg1) + (let ((a2-2 (sql-query s3-0))) + (when (!= (-> a2-2 error) 'select) + (format 0 "ERROR: sql: select error ~A for ~A~%" a2-2 obj) + (return #f) + ) + (set! (-> arg0 nav_graph_id) (the-as uint (string->int (-> a2-2 data 0)))) + ) + ) + (dotimes (v1-7 (-> obj node-count)) + (let ((a1-6 (-> arg0 node-array data (-> arg0 node-array length))) + (a0-11 (-> obj node-array v1-7)) + ) + (logior! (-> a1-6 mysql-save-flag) (mysql-save-flag insert)) + (set! (-> a1-6 runtime-id) (-> a0-11 id)) + (set! (-> a1-6 nav_graph_id) (-> arg0 nav_graph_id)) + (let ((t0-0 a0-11) + (a2-8 (-> a1-6 position)) + ) + (set! (-> a2-8 quad) (-> t0-0 position quad)) + (set! (-> a2-8 w) 1.0) + ) + (set! (-> a1-6 level_name) (-> a0-11 level)) + (set! (-> a1-6 angle) (the float (-> a0-11 angle))) + (let ((a2-13 a0-11)) + (set! (-> a1-6 radius) (* 1024.0 (the float (-> a2-13 radius)))) + ) + (set! (-> a1-6 nav_node_flag) (the-as nav-node-flag (-> a0-11 flags))) + (set! (-> a1-6 nav_mesh_id) (-> a0-11 nav-mesh-id)) + (+! (-> arg0 node-array length) 1) + (dotimes (a1-10 (-> a0-11 branch-count)) + (let ((a2-22 (-> arg0 edge-array data (-> arg0 edge-array length))) + (a3-8 (-> a0-11 branch-array a1-10)) + ) + (logior! (-> a2-22 mysql-save-flag) (mysql-save-flag insert)) + (set! (-> a2-22 nav_graph_id) (-> arg0 nav_graph_id)) + (set! (-> a2-22 runtime-id) (the-as uint (-> arg0 edge-array length))) + (set! (-> a2-22 runtime-node-id-1) (the-as int (-> a0-11 id))) + (set! (-> a2-22 runtime-node-id-2) (the-as int (-> a3-8 dest-node id))) + (set! (-> a2-22 directionality) (nav-directionality default)) + (let ((t0-12 a3-8)) + (set! (-> a2-22 speed_limit) (* 1024.0 (the float (-> t0-12 speed-limit)))) + ) + (let ((t0-15 a3-8)) + (set! (-> a2-22 density) (* 0.0078125 (the float (-> t0-15 density)))) + ) + (set! (-> a2-22 nav_clock_mask) (the-as nav-clock-mask (-> a3-8 clock-mask))) + (set! (-> a2-22 nav_clock_type) (the-as nav-clock-type (-> a3-8 clock-type))) + (set! (-> a2-22 width) (* 256.0 (the float (-> a3-8 width)))) + ) + (+! (-> arg0 edge-array length) 1) + ) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch object vs nav-graph. +(defmethod new nav-graph ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int) (arg2 int) (arg3 uint)) + (let ((s1-0 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size)))))) + (when (zero? (the-as nav-graph s1-0)) + (set! s1-0 0) + (goto cfg-4) + ) + (set! (-> (the-as nav-graph s1-0) node-count) arg0) + (set! (-> (the-as nav-graph s1-0) branch-count) arg1) + (set! (-> (the-as nav-graph s1-0) link-count) arg2) + (set! (-> (the-as nav-graph s1-0) node-array) + (the-as (inline-array nav-node) (malloc allocation (* arg0 32))) + ) + (set! (-> (the-as nav-graph s1-0) branch-array) + (the-as (inline-array nav-branch) (malloc allocation (* arg1 16))) + ) + (set! (-> (the-as nav-graph s1-0) link-array) + (the-as (inline-array nav-graph-link) (malloc allocation (* 48 arg2))) + ) + (set! (-> (the-as nav-graph s1-0) first-node) 0) + (set! (-> (the-as nav-graph s1-0) patched) #f) + (set! (-> (the-as nav-graph s1-0) id) arg3) + (label cfg-4) + (the-as nav-graph s1-0) + ) + ) + +(defmethod from-editor nav-graph ((obj nav-graph) (arg0 mysql-nav-graph) (arg1 symbol)) + (local-vars + (v1-4 symbol) + (v1-6 symbol) + (v1-37 symbol) + (sv-16 int) + (sv-32 int) + (sv-48 mysql-nav-node) + (sv-64 nav-branch) + (sv-80 nav-graph-link) + (sv-96 nav-node) + (sv-112 int) + ) + (set! (-> obj node-count) 0) + (set! (-> obj branch-count) 0) + (set! (-> obj link-count) 0) + (mysql-nav-graph-method-20 arg0) + (let ((s5-0 0)) + (let ((s2-0 0)) + (b! #t cfg-34 :delay (nop!)) + (label cfg-1) + (let ((s0-0 (-> arg0 node-array data s2-0))) + (let ((a0-3 (= arg1 #f))) + (b! a0-3 cfg-4 :likely-delay (set! v1-4 a0-3)) + ) + (set! v1-4 (= arg1 (-> s0-0 level_name))) + (label cfg-4) + (b! (not v1-4) cfg-7 :likely-delay (set! v1-6 v1-4)) + (set! v1-6 (zero? (logand (-> s0-0 mysql-save-flag) (mysql-save-flag delete)))) + (label cfg-7) + (b! (not v1-6) cfg-27 :delay (nop!)) + (set! sv-16 (temp-edge-size s0-0)) + (let ((s1-0 (debug-add-node obj sv-16))) + (b! (not s1-0) cfg-36 :delay (nop!)) + (set! (-> s1-0 id) (the-as uint (if arg1 + (-> s0-0 level-node-index) + s2-0 + ) + ) + ) + (set! (-> s1-0 flags) (the-as nav-node-flag-byte (-> s0-0 nav_node_flag))) + (set-pos-xyz s1-0 (-> s0-0 position)) + (set-angle s1-0 (-> s0-0 angle)) + (set-radius s1-0 (-> s0-0 radius)) + (set! (-> s1-0 level) (-> s0-0 level_name)) + (set! (-> s1-0 nav-mesh-id) (-> s0-0 nav_mesh_id)) + (when (!= (-> obj branch-array s5-0) (-> s1-0 branch-array 0)) + (format 0 "nav-graph::from-editor: ERROR something went awry in allocate-branches~%") + (break!) + 0 + ) + (let ((s0-1 (the-as object (-> s0-0 temp-edge-list)))) + (set! sv-32 sv-16) + (b! #t cfg-25 :delay (nop!)) + (label cfg-15) + (set! sv-32 (+ sv-32 -1)) + (set! sv-64 (-> obj branch-array s5-0)) + (set-src-node sv-64 s1-0) + (set-speed-limit sv-64 (-> (the-as mysql-nav-edge s0-1) speed_limit)) + (set-density sv-64 (-> (the-as mysql-nav-edge s0-1) density)) + (set-width sv-64 (-> (the-as mysql-nav-edge s0-1) width)) + (set! (-> sv-64 clock-type) (the-as nav-branch-clock-type (-> (the-as mysql-nav-edge s0-1) nav_clock_type))) + (set! (-> sv-64 clock-mask) (the-as nav-branch-clock-mask (-> (the-as mysql-nav-edge s0-1) nav_clock_mask))) + (set! sv-48 (-> arg0 node-array data (-> (the-as mysql-nav-edge s0-1) runtime-node-id-2))) + (let ((a0-23 (= arg1 #f))) + (b! a0-23 cfg-18 :likely-delay (set! v1-37 a0-23)) + ) + (set! v1-37 (= arg1 (-> sv-48 level_name))) + (label cfg-18) + (b! (not v1-37) cfg-23 :delay (nop!)) + (let ((t9-11 (method-of-type nav-branch set-dst-node)) + (a1-11 (-> obj node-array (if arg1 + (-> sv-48 level-node-index) + (-> (the-as mysql-nav-edge s0-1) runtime-node-id-2) + ) + ) + ) + ) + (t9-11 sv-64 a1-11) + ) + (b! #t cfg-24 :delay (nop!)) + (label cfg-23) + (set-dst-node sv-64 (the-as nav-node #f)) + (set! sv-112 (-> obj link-count)) + (set! sv-80 (-> obj link-array sv-112)) + (set! (-> sv-80 dest-graph-id) (-> (lookup-level-info2 arg0 sv-48 #f) level-id)) + (set! (-> sv-80 src-branch-id) (the-as uint s5-0)) + (set! (-> sv-80 dest-node-id) (the-as uint (-> sv-48 level-node-index))) + (set! (-> sv-80 dest-graph) #f) + (set! sv-96 (-> sv-80 dummy-node)) + (set! (-> sv-96 id) (the-as uint #xffff)) + (set! (-> sv-96 flags) (the-as nav-node-flag-byte (-> sv-48 nav_node_flag))) + (set-pos-xyz sv-96 (-> sv-48 position)) + (set-angle sv-96 (-> sv-48 angle)) + (set-radius sv-96 (-> sv-48 radius)) + (set! (-> sv-96 level) (-> sv-48 level_name)) + (set! (-> sv-96 nav-mesh-id) (-> sv-48 nav_mesh_id)) + (set-dst-node sv-64 (-> sv-80 dummy-node)) + (format #t "outputting link ~d~%" sv-112) + (+! (-> obj link-count) 1) + (label cfg-24) + (+! s5-0 1) + (set! s0-1 (-> (the-as mysql-nav-edge s0-1) temp-next-edge)) + ) + ) + (label cfg-25) + (b! (nonzero? sv-32) cfg-15 :delay (nop!)) + (b! #t cfg-33 :delay (nop!)) + (label cfg-27) + (let ((v1-78 (the-as object (-> s0-0 temp-edge-list)))) + (b! #t cfg-31 :delay (nop!)) + (label cfg-28) + (when (= arg1 (-> arg0 node-array data (-> (the-as mysql-nav-edge v1-78) runtime-node-id-2) level_name)) + ) + (set! v1-78 (-> (the-as mysql-nav-edge v1-78) temp-next-edge)) + (label cfg-31) + (b! v1-78 cfg-28 :delay (nop!)) + ) + ) + (label cfg-33) + (+! s2-0 1) + (label cfg-34) + (b! (< s2-0 (-> arg0 node-array length)) cfg-1) + ) + (format #t "branch-count ~d~%" s5-0) + ) + (set! (-> obj patched) #t) + (label cfg-36) + 0 + (none) + ) + +;; WARN: Return type mismatch nav-graph vs none. +(defun make-nav-graph ((arg0 mysql-nav-graph) (arg1 symbol)) + (mysql-nav-graph-method-20 arg0) + (let ((s4-0 (the-as nav-graph #f)) + (v1-2 (the-as mysql-nav-graph-level-info #f)) + ) + (dotimes (a0-2 (-> arg0 level-info-array-length)) + (let ((a1-3 (-> arg0 level-info-array a0-2))) + (if (= (-> a1-3 level) arg1) + (set! v1-2 a1-3) + ) + ) + ) + (when v1-2 + (set! s4-0 + (new 'debug 'nav-graph (-> v1-2 node-count) (-> v1-2 branch-count) (-> v1-2 to-link-count) (-> v1-2 level-id)) + ) + (if s4-0 + (from-editor s4-0 arg0 arg1) + ) + ) + ) + (none) + ) diff --git a/goal_src/jak2/levels/city/common/pilot-states.gc b/goal_src/jak2/levels/city/common/pilot-states.gc index fec2c5cc4f..5e7d03bd9a 100644 --- a/goal_src/jak2/levels/city/common/pilot-states.gc +++ b/goal_src/jak2/levels/city/common/pilot-states.gc @@ -4,6 +4,1082 @@ ;; name: pilot-states.gc ;; name in dgo: pilot-states ;; dgos: CWI +(define-extern *pilot-get-on-mods* surface) +(define-extern *pilot-get-off-mods* surface) ;; DECOMP BEGINS +(defstate target-pilot-start (target) + :event target-pilot-handler + :exit (the-as (function none :behavior target) target-pilot-exit) + :code (behavior ((arg0 handle) (arg1 symbol) (arg2 symbol)) + (target-pilot-init arg0 arg2) + (suspend) + (remove-exit) + (if arg1 + (go target-pilot-stance) + (go target-pilot-get-on) + ) + (none) + ) + :post target-post + ) + +;; WARN: Return type mismatch symbol vs none. +;; WARN: new jak 2 until loop case, check carefully +(defbehavior target-pilot-bike-anim-loop target () + (ja-channel-push! 3 (seconds 0.1)) + (ja :group! (-> self draw art-group data 210)) + (ja :chan 1 :group! (-> self draw art-group data 209)) + (ja :chan 2 :group! (-> self draw art-group data 214)) + (until #f + (let ((gp-0 (-> self pilot))) + (let ((f30-0 (* 5.0 (- 1.0 (-> gp-0 left-right-interp))))) + (ja :num-func num-func-identity :frame-num (ja-aframe f30-0 0)) + (let ((f0-3 (fmax 0.0 (fmin 1.0 (* 0.5 (+ 1.0 (* 1.42 (+ -0.3 (-> gp-0 front-back-interp)))))))) + (s5-1 (-> self skel root-channel 1)) + ) + (set! (-> s5-1 frame-interp 1) f0-3) + (set! (-> s5-1 frame-interp 0) f0-3) + (set! (-> s5-1 num-func) num-func-identity) + (set! (-> s5-1 frame-num) (ja-aframe f30-0 1)) + ) + ) + (let ((f0-6 (* 5.0 (- 1.0 (-> gp-0 up-down-interp)))) + (s5-2 (-> self skel root-channel 2)) + ) + (let ((f1-7 (fabs (-> gp-0 up-down-interp)))) + (set! (-> s5-2 frame-interp 1) f1-7) + (set! (-> s5-2 frame-interp 0) f1-7) + ) + (set! (-> s5-2 num-func) num-func-identity) + (set! (-> s5-2 frame-num) (ja-aframe f0-6 2)) + ) + ) + (can-play-stance-amibent?) + (suspend) + ) + #f + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +;; WARN: new jak 2 until loop case, check carefully +(defbehavior target-pilot-car-anim-loop target () + (ja-channel-push! 3 (seconds 0.1)) + (ja :group! (-> self draw art-group data 203)) + (ja :chan 1 :group! (-> self draw art-group data 202)) + (ja :chan 2 :group! (-> self draw art-group data 213)) + (until #f + (let ((gp-0 (-> self pilot))) + (let ((f30-0 (* 5.0 (+ 1.0 (-> gp-0 left-right-interp))))) + (ja :num-func num-func-identity :frame-num (ja-aframe f30-0 0)) + (let ((s5-1 (-> self skel root-channel 1))) + (let ((f0-3 (* 0.5 (+ 1.0 (-> gp-0 front-back-interp))))) + (set! (-> s5-1 frame-interp 1) f0-3) + (set! (-> s5-1 frame-interp 0) f0-3) + ) + (set! (-> s5-1 num-func) num-func-identity) + (set! (-> s5-1 frame-num) (ja-aframe f30-0 1)) + ) + ) + (let ((f0-6 (* 10.0 (- 1.0 (-> gp-0 up-down-interp)))) + (s5-2 (-> self skel root-channel 2)) + ) + (let ((f1-7 (fabs (-> gp-0 up-down-interp)))) + (set! (-> s5-2 frame-interp 1) f1-7) + (set! (-> s5-2 frame-interp 0) f1-7) + ) + (set! (-> s5-2 num-func) num-func-identity) + (set! (-> s5-2 frame-num) (ja-aframe f0-6 2)) + ) + ) + (suspend) + ) + #f + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +;; WARN: new jak 2 until loop case, check carefully +(defbehavior target-daxter-pilot-car-anim-loop target () + (ja-channel-push! 3 (seconds 0.1)) + (ja :group! (-> self draw art-group data 453)) + (ja :chan 1 :group! (-> self draw art-group data 452)) + (ja :chan 2 :group! (-> self draw art-group data 454)) + (until #f + (let ((gp-0 (-> self pilot))) + (let ((f30-0 (* 5.0 (+ 1.0 (-> gp-0 left-right-interp))))) + (ja :num-func num-func-identity :frame-num (ja-aframe f30-0 0)) + (let ((s5-1 (-> self skel root-channel 1))) + (let ((f0-3 (* 0.5 (+ 1.0 (-> gp-0 front-back-interp))))) + (set! (-> s5-1 frame-interp 1) f0-3) + (set! (-> s5-1 frame-interp 0) f0-3) + ) + (set! (-> s5-1 num-func) num-func-identity) + (set! (-> s5-1 frame-num) (ja-aframe f30-0 1)) + ) + ) + (let ((f0-6 (* 10.0 (- 1.0 (-> gp-0 up-down-interp)))) + (s5-2 (-> self skel root-channel 2)) + ) + (let ((f1-7 (fabs (-> gp-0 up-down-interp)))) + (set! (-> s5-2 frame-interp 1) f1-7) + (set! (-> s5-2 frame-interp 0) f1-7) + ) + (set! (-> s5-2 num-func) num-func-identity) + (set! (-> s5-2 frame-num) (ja-aframe f0-6 2)) + ) + ) + (suspend) + ) + #f + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defbehavior target-pilot-trans target () + (let* ((gp-0 (-> self pilot)) + (s5-0 (handle->process (-> gp-0 vehicle))) + ) + (cond + ((not s5-0) + (ja-channel-set! 0) + (go target-falling #f) + ) + (#t + (let ((s4-0 (new 'stack-no-clear 'inline-array 'vector 10))) + (set! (-> gp-0 accel-array 7 quad) (-> gp-0 accel-array 6 quad)) + (set! (-> gp-0 accel-array 6 quad) (-> gp-0 accel-array 5 quad)) + (set! (-> gp-0 accel-array 5 quad) (-> gp-0 accel-array 4 quad)) + (set! (-> gp-0 accel-array 4 quad) (-> gp-0 accel-array 3 quad)) + (set! (-> gp-0 accel-array 3 quad) (-> gp-0 accel-array 2 quad)) + (set! (-> gp-0 accel-array 2 quad) (-> gp-0 accel-array 1 quad)) + (set! (-> gp-0 accel-array 1 quad) (-> gp-0 accel-array 0 quad)) + (vehicle-method-115 (the-as vehicle s5-0) (the-as vector (-> gp-0 accel-array))) + (vector-reset! (-> s4-0 0)) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (the-as vector (-> gp-0 accel-array)) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 1) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 2) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 3) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 4) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 5) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 6) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 7) 1.0) + (vector-float*! (-> s4-0 0) (-> s4-0 0) 0.5) + (matrix-transpose! (the-as matrix (-> s4-0 1)) (-> self node-list data 0 bone transform)) + (vector-rotate*! (-> gp-0 local-accel) (-> s4-0 0) (the-as matrix (-> s4-0 1))) + ) + (vehicle-method-116 (the-as vehicle s5-0) (the-as (pointer vehicle-controls) (-> gp-0 controls))) + (let ((f30-0 (* 182.04445 (* 0.6 (the float (-> self clock frame-counter))))) + (s5-1 (-> gp-0 local-accel)) + ) + (let ((f3-0 + (+ (-> gp-0 controls steering) (* 0.03 (sin f30-0)) (* -1.0 (-> s5-1 x) (-> gp-0 left-right-accel-factor))) + ) + ) + (set! (-> gp-0 left-right-interp) + (fmax + -1.0 + (fmin + 1.0 + (+ (-> gp-0 left-right-interp) (* 8.0 (- f3-0 (-> gp-0 left-right-interp)) (-> self clock seconds-per-frame))) + ) + ) + ) + ) + (let ((f3-4 + (+ (-> gp-0 controls lean-z) (* 0.03 (cos f30-0)) (* -1.0 (-> s5-1 z) (-> gp-0 front-back-accel-factor))) + ) + ) + (set! (-> gp-0 front-back-interp) + (fmax + -1.0 + (fmin + 1.0 + (+ (-> gp-0 front-back-interp) (* 8.0 (- f3-4 (-> gp-0 front-back-interp)) (-> self clock seconds-per-frame))) + ) + ) + ) + ) + (let ((f3-8 (+ (* 0.03 (cos f30-0)) (* -1.0 (-> s5-1 y) (-> gp-0 up-down-accel-factor))))) + (set! (-> gp-0 up-down-interp) + (fmax + -1.0 + (fmin + 1.0 + (+ (-> gp-0 up-down-interp) (* 8.0 (- f3-8 (-> gp-0 up-down-interp)) (-> self clock seconds-per-frame))) + ) + ) + ) + ) + ) + (when (and (-> self next-state) (= (-> self next-state name) 'target-pilot-stance)) + (let* ((v1-67 (-> gp-0 accel-array)) + (f0-27 (+ (* (-> v1-67 0 x) (-> v1-67 0 x)) (* (-> v1-67 0 z) (-> v1-67 0 z)))) + ) + (if (or (and (-> self pilot as-daxter?) (let ((f1-20 1024000.0)) + (< (* f1-20 f1-20) f0-27) + ) + ) + (let ((f1-23 2048000.0)) + (< (* f1-23 f1-23) f0-27) + ) + ) + (go target-pilot-impact) + ) + ) + ) + ) + (else + (go target-pilot-get-off) + ) + ) + ) + (none) + ) + +(defbehavior target-pilot-signal-ready target () + (when (not (logtest? (-> self focus-status) (focus-status pilot-riding))) + (logior! (-> self focus-status) (focus-status pilot-riding)) + (send-event (handle->process (-> self pilot vehicle)) 'pilot-on (-> self pilot seat-index)) + ) + ) + +(defstate target-pilot-stance (target) + :event target-pilot-handler + :exit (the-as (function none :behavior target) target-pilot-exit) + :trans (behavior () + (target-pilot-trans) + (none) + ) + :code (behavior () + (target-pilot-signal-ready) + (logior! (-> self state-flags) (state-flags sf6)) + (set! (-> self control mod-surface) *pilot-mods*) + (logior! (-> self control status) (collide-status on-surface on-ground)) + (cond + ((-> self pilot as-daxter?) + (target-daxter-pilot-car-anim-loop) + ) + ((zero? (-> self pilot stance)) + (target-pilot-bike-anim-loop) + ) + (else + (target-pilot-car-anim-loop) + ) + ) + (none) + ) + :post (behavior () + (target-pilot-post) + (none) + ) + ) + +(defstate target-pilot-impact (target) + :event target-pilot-handler + :exit (the-as (function none :behavior target) target-pilot-exit) + :trans (behavior () + (target-pilot-trans) + (none) + ) + :code (behavior () + (local-vars (v1-1 float) (v1-252 int)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (-> self pilot))) + (.lvf vf1 (&-> (-> gp-0 local-accel) 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-1 vf1) + (let ((f0-0 v1-1) + (v1-2 (new 'stack-no-clear 'vector)) + ) + (set! (-> v1-2 quad) (-> gp-0 local-accel quad)) + (set! (-> v1-2 x) (* 4.0 (-> v1-2 x))) + (vector-float*! v1-2 v1-2 (/ 1.0 (sqrtf f0-0))) + (let ((s5-0 (cond + ((< 0.707 (-> v1-2 x)) + 5 + ) + ((< (-> v1-2 x) -0.707) + 4 + ) + ((< 0.707 (-> v1-2 y)) + 3 + ) + ((< (-> v1-2 y) -0.707) + 2 + ) + ((< 0.707 (-> v1-2 z)) + 1 + ) + ((< (-> v1-2 z) -0.707) + 0 + ) + (else + 6 + ) + ) + ) + ) + (cond + ((-> self pilot as-daxter?) + (ja-channel-push! 1 (seconds 0.05)) + (cond + ((= s5-0 4) + (ja-no-eval :group! (-> self draw art-group data 457) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 457)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((= s5-0 5) + (ja-no-eval :group! (-> self draw art-group data 458) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 458)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((zero? s5-0) + (ja-no-eval :group! (-> self draw art-group data 455) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 455)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((= s5-0 1) + (ja-no-eval :group! (-> self draw art-group data 456) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 456)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + (else + (ja-no-eval :group! (-> self draw art-group data 455) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 455)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ) + ) + ((zero? (-> self pilot stance)) + (ja-channel-push! 1 (seconds 0.05)) + (let ((v1-131 s5-0)) + (cond + ((= v1-131 4) + (ja-no-eval :group! (-> self draw art-group data 232) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 232)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((= v1-131 5) + (ja-no-eval :group! (-> self draw art-group data 233) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 233)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((zero? v1-131) + (ja-no-eval :group! (-> self draw art-group data 211) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 211)) frames num-frames) -1))) + :frame-num (ja-aframe 0.0 0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((= v1-131 1) + (ja-no-eval :group! (-> self draw art-group data 212) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 212)) frames num-frames) -1))) + :frame-num (ja-aframe 0.0 0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + (else + (ja-no-eval :group! (-> self draw art-group data 215) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 215)) frames num-frames) -1))) + :frame-num (ja-aframe 0.0 0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ) + ) + ) + ((begin (ja-channel-push! 1 (seconds 0.05)) (set! v1-252 s5-0) (= v1-252 4)) + (ja-no-eval :group! (-> self draw art-group data 234) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 234)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((= v1-252 5) + (ja-no-eval :group! (-> self draw art-group data 235) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 235)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((zero? v1-252) + (ja-no-eval :group! (-> self draw art-group data 204) + :num! (seek! + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 204)) frames num-frames) -1)) + 1.3 + ) + :frame-num (ja-aframe 4.0 0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek! max 1.3)) + ) + ) + ((= v1-252 1) + (ja-no-eval :group! (-> self draw art-group data 205) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 205)) frames num-frames) -1))) + :frame-num (ja-aframe 2.0 0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + (else + (ja-no-eval :group! (-> self draw art-group data 208) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 208)) frames num-frames) -1))) + :frame-num (ja-aframe 0.0 0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ) + ) + ) + (.svf (&-> (-> gp-0 accel-array) 0 quad) vf0) + ) + (go target-pilot-stance) + (none) + ) + ) + :post (behavior () + (target-pilot-post) + (none) + ) + ) + +(let ((v1-9 (copy *empty-mods* 'loading-level))) + (set! (-> v1-9 flags) (surface-flag)) + (set! *pilot-get-on-mods* v1-9) + ) + +(defstate target-pilot-get-on (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('end-mode) + (cond + ((logtest? (-> self focus-status) (focus-status pilot-riding)) + (go target-pilot-get-off) + ) + (else + (ja-channel-set! 0) + (go target-falling #f) + ) + ) + ) + (else + (target-standard-event-handler proc arg1 event-type event) + ) + ) + ) + :exit (the-as (function none :behavior target) target-pilot-exit) + :trans (behavior () + (let* ((s5-0 (handle->process (-> self pilot vehicle))) + (gp-0 (if (type? s5-0 vehicle) + s5-0 + ) + ) + ) + (cond + ((not gp-0) + (ja-channel-set! 0) + (go target-falling #f) + ) + ((logtest? (-> (the-as vehicle gp-0) focus-status) (focus-status dead)) + (go target-pilot-get-off) + ) + (else + (compute-seat-position (the-as vehicle gp-0) (-> self control unknown-vector38) (-> self pilot seat-index)) + (set! (-> self control unknown-vector40 quad) (-> (the-as vehicle gp-0) root-override-2 quat quad)) + ) + ) + ) + (none) + ) + :code (behavior () + (set! (-> self focus-status) (logior (focus-status pilot) (-> self focus-status))) + (logior! (-> self state-flags) (state-flags sf6)) + (set! (-> self alt-cam-pos quad) (-> self control camera-pos quad)) + (let ((gp-0 (if (zero? (-> self pilot stance)) + (-> self draw art-group data 201) + (-> self draw art-group data 200) + ) + ) + ) + (ja-channel-set! 1) + (set! (-> self control mod-surface) *pilot-get-on-mods*) + (send-event (ppointer->process (-> self manipy)) 'draw #t) + (set! (-> self neck flex-blend) 0.0) + (set! (-> self control unknown-vector37 quad) (-> self control trans quad)) + (set! (-> self control unknown-vector39 quad) (-> self control quat quad)) + (ja :group! gp-0 + :num! (seek! (the float (+ (-> (the-as art-joint-anim gp-0) frames num-frames) -1))) + :frame-num 0.0 + ) + ) + (until (ja-done? 0) + (let ((f30-0 (sin (lerp-scale 0.0 16384.0 (ja-aframe-num 0) 0.0 10.0)))) + (let ((f28-0 (lerp-scale 0.0 1.0 (ja-aframe-num 0) 0.0 10.0))) + (vector-lerp! + (-> self control trans) + (-> self control unknown-vector37) + (-> self control unknown-vector38) + f30-0 + ) + (set! (-> self control trans y) + (lerp (-> self control unknown-vector37 y) (-> self control unknown-vector38 y) f28-0) + ) + ) + (quaternion-slerp! + (-> self control quat-for-control) + (the-as quaternion (-> self control unknown-vector39)) + (the-as quaternion (-> self control unknown-vector40)) + f30-0 + ) + ) + (rot->dir-targ! (-> self control)) + (if (>= (ja-aframe-num 0) 20.5) + (target-pilot-signal-ready) + ) + (suspend) + (let ((a1-7 (handle->process (-> self pilot vehicle)))) + (if a1-7 + (set! (-> self alt-cam-pos quad) (-> (the-as vehicle a1-7) rbody state position quad)) + ) + ) + (ja :num! (seek!)) + ) + (go target-pilot-stance) + (none) + ) + :post target-no-move-post + ) + +(let ((v1-12 (copy *forward-jump-mods* 'loading-level))) + (set! (-> v1-12 fric) 0.0) + (set! (-> v1-12 nonlin-fric-dist) 0.0) + (set! (-> v1-12 turnv) 0.0) + (set! (-> v1-12 turnvv) 0.0) + (set! (-> v1-12 tiltv) 131072.0) + (set! (-> v1-12 tiltvf) 30.0) + (set! (-> v1-12 mult-hook) + (the-as + (function surface surface surface int none) + (lambda ((arg0 object) (arg1 object) (arg2 object) (arg3 int)) + (case arg3 + ((1) + (persist-with-delay *setting-control* 'rapid-tracking (seconds 0.05) 'rapid-tracking #f 0.0 0) + ) + ) + (none) + ) + ) + ) + (set! *pilot-get-off-mods* v1-12) + ) + +(defstate target-pilot-get-off (target) + :event target-standard-event-handler + :exit (the-as (function none :behavior target) target-pilot-exit) + :trans (behavior () + (let ((gp-0 (handle->process (-> self pilot vehicle)))) + (when (not (if (type? gp-0 vehicle) + gp-0 + ) + ) + (ja-channel-set! 0) + (go target-falling #f) + ) + ) + (none) + ) + :code (behavior () + (local-vars (f30-0 float)) + (let ((v1-1 (-> self control root-prim))) + (set! (-> v1-1 prim-core collide-as) (-> self control backup-collide-as)) + (set! (-> v1-1 prim-core collide-with) (-> self control backup-collide-with)) + ) + (logclear! (-> self focus-status) (focus-status pilot-riding)) + (set! (-> self control mod-surface) *pilot-get-off-mods*) + (rot->dir-targ! (-> self control)) + (send-event *camera* 'set-dist #f #f) + (set! (-> self neck flex-blend) 0.0) + 0.0 + (let ((gp-0 (cond + ((zero? (-> self pilot stance)) + (set! f30-0 7.2) + (-> self draw art-group data 216) + ) + (else + (set! f30-0 15.2) + (-> self draw art-group data 199) + ) + ) + ) + ) + (ja-channel-push! 1 (seconds 0.05)) + (ja-no-eval :group! gp-0 :num! (seek! (ja-aframe f30-0 0) 2.0) :frame-num 0.0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek! (ja-aframe f30-0 0) 2.0)) + ) + (let ((v1-29 (camera-matrix)) + (gp-2 (new 'stack-no-clear 'inline-array 'vector 10)) + ) + (set! (-> gp-2 0 quad) (-> v1-29 vector 0 quad)) + (set! (-> gp-2 1 quad) (-> v1-29 vector 2 quad)) + (set! (-> gp-2 1 y) 0.0) + (vector-normalize! (-> gp-2 1) 1.0) + (vector-reset! (-> gp-2 2)) + (vector+float*! + (-> gp-2 2) + (-> gp-2 2) + (-> gp-2 0) + (* 16384.0 (analog-input (the-as int (-> *cpad-list* cpads 0 leftx)) 128.0 48.0 110.0 -1.0)) + ) + (vector+float*! + (-> gp-2 2) + (-> gp-2 2) + (-> gp-2 1) + (* 16384.0 (analog-input (the-as int (-> *cpad-list* cpads 0 lefty)) 128.0 48.0 110.0 -1.0)) + ) + (vector+! (-> self control transv) (-> self control transv) (-> gp-2 2)) + ) + (go target-jump 10240.0 10240.0 *pilot-get-off-mods*) + (none) + ) + :post target-pilot-post + ) + +(defstate target-pilot-grab (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (cond + ((and (= event-type 'query) (= (-> event param 0) 'mode)) + (-> self state name) + ) + (else + (case event-type + (('end-mode) + (go target-pilot-stance) + ) + (('clone-anim) + (go target-pilot-clone-anim (process->handle (the-as process (-> event param 0)))) + ) + (('vehicle-crash) + (go target-grab 'stance) + ) + (else + (target-generic-event-handler proc arg1 event-type event) + ) + ) + ) + ) + ) + :enter (behavior () + (set! (-> self control mod-surface) *grab-mods*) + (set! (-> self neck flex-blend) 0.0) + (logior! (-> self state-flags) (state-flags sf2)) + (logior! (-> self focus-status) (focus-status grabbed)) + (none) + ) + :exit (behavior () + (logclear! (-> self state-flags) (state-flags sf2)) + (logclear! (-> self focus-status) (focus-status grabbed)) + (logclear! (-> self water flags) (water-flags jump-out)) + ((-> target-pilot-start exit)) + (none) + ) + :code (behavior () + (until #f + (set-forward-vel 0.0) + (suspend) + ) + #f + (none) + ) + :post target-pilot-post + ) + +(defstate target-pilot-clone-anim (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (if (and (= event-type 'trans) (= (-> event param 0) 'restore)) + (set! (-> self control unknown-word04) (the-as uint #f)) + ) + ((-> target-pilot-grab event) proc arg1 event-type event) + ) + :enter (-> target-clone-anim enter) + :exit (behavior () + (set! (-> self control draw-offset y) (the-as float (-> self control unknown-word04))) + (set! (-> self control cspace-offset y) (-> self control draw-offset y)) + (send-event (ppointer->process (-> self sidekick)) 'matrix #f) + ((-> target-clone-anim exit)) + ((-> target-pilot-start exit)) + (vector-reset! (-> self control transv)) + (none) + ) + :code (behavior ((arg0 handle)) + (set! (-> self control unknown-word04) (the-as uint (-> self control draw-offset y))) + (set! (-> self control draw-offset y) 0.0) + (send-event (ppointer->process (-> self sidekick)) 'matrix 'play-anim) + (clone-anim arg0 #t "") + (go target-pilot-stance) + (none) + ) + :post (behavior () + (vector+! (-> self pilot pilot-trans) (-> self control trans) (-> self control cspace-offset)) + (quaternion-copy! (the-as quaternion (-> self pilot pilot-quat)) (-> self control quat)) + (set! (-> self pilot pilot-scale quad) (-> self control scale quad)) + (target-no-ja-move-post) + (none) + ) + ) + +(defstate target-pilot-edge-grab (target) + :event (-> target-edge-grab event) + :enter (behavior ((arg0 pilot-edge-grab-info)) + (set! (-> self control status) (collide-status)) + (let ((gp-0 *edge-grab-info*)) + (mem-copy! (the-as pointer (-> gp-0 pilot-edge-grab)) (the-as pointer arg0) 40) + (set! (-> gp-0 pilot-grab-interp) 0.0) + (set! (-> gp-0 pilot-start-grab-pos quad) (-> self control trans quad)) + (set! (-> gp-0 actor-handle) (-> arg0 handle)) + ((-> target-edge-grab enter)) + (let* ((s5-1 (handle->process (-> gp-0 actor-handle))) + (a0-9 (if (type? s5-1 process-focusable) + s5-1 + ) + ) + ) + (set! (-> gp-0 pilot-edge-grab?) + (if (and a0-9 + (< 24576.0 (fabs (- (-> (get-trans (the-as process-focusable a0-9) 0) y) (-> self control trans y)))) + ) + 'target-double-jump + 'target-jump + ) + ) + ) + ) + (none) + ) + :exit (-> target-edge-grab exit) + :trans (-> target-edge-grab trans) + :code (-> target-edge-grab code) + :post target-no-move-post + ) + +(defstate target-pilot-hit (target) + :event target-generic-event-handler + :exit (behavior () + (if (not (and (-> self next-state) (= (-> self next-state name) 'target-death))) + (logclear! (-> self focus-status) (focus-status dead hit)) + ) + ((-> target-pilot-start exit)) + (none) + ) + :code (behavior ((arg0 symbol) (arg1 attack-info)) + (local-vars (sv-16 attack-info)) + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self neck flex-blend) 0.0) + (set! sv-16 (-> self attack-info)) + (let ((v1-4 sv-16)) + (set! (-> v1-4 attacker) (the-as handle #f)) + (set! (-> v1-4 mode) 'generic) + (set! (-> v1-4 shove-back) 6144.0) + (set! (-> v1-4 shove-up) 4915.2) + (set! (-> v1-4 angle) #f) + (set! (-> v1-4 trans quad) (-> self control trans quad)) + (set! (-> v1-4 control) 0.0) + (set! (-> v1-4 invinc-time) (the-as time-frame (-> *TARGET-bank* hit-invulnerable-timeout))) + (set! (-> v1-4 damage) (-> *FACT-bank* health-default-inc)) + ) + (combine! sv-16 arg1 self) + (pickup-collectable! (-> self fact-override) (pickup-type health) -1000.0 (the-as handle #f)) + (go target-pilot-death (-> sv-16 mode)) + (none) + ) + :post target-no-stick-post + ) + +(defstate target-pilot-death (target) + :event (-> target-death event) + :exit (behavior () + ((-> target-pilot-start exit)) + ((-> target-death exit)) + (none) + ) + :code (behavior ((arg0 symbol)) + (set! (-> self control unknown-word04) (the-as uint #f)) + (set! (-> self control did-move-to-pole-or-max-jump-height) + (the-as float (send-event (handle->process (-> self attack-info attacker)) 'target 'die arg0)) + ) + (set! (-> self neck flex-blend) 0.0) + (target-timed-invulnerable-off self 0) + (case arg0 + (('bot) + (set-setting! 'process-mask 'set 0 (process-mask platform projectile death)) + ) + (('endlessfall 'instant-death 'lava 'dark-eco-pool 'melt 'explode 'grenade) + (set-setting! 'process-mask 'set 0 (process-mask enemy platform projectile death)) + ) + (else + (set-setting! 'process-mask 'set 0 (process-mask enemy platform projectile death)) + (when (using-gun? self) + (send-event (ppointer->process (-> self gun gun)) 'die) + (target-gun-end-mode #f) + ) + ) + ) + (set-setting! 'mode-name 'cam-fixed 0 0) + (set-setting! 'interp-time 'abs 0 0) + (apply-settings *setting-control*) + (set! (-> self control transv quad) (the-as uint128 0)) + (logior! (-> self focus-status) (focus-status dead)) + (case arg0 + (('melt 'grenade 'explode) + (let ((s5-0 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) s5-0) (seconds 0.2)) + (suspend) + ) + ) + (case arg0 + (('dark-eco-pool) + (sound-play "death-darkeco") + (let ((s5-2 (get-process *default-dead-pool* part-tracker #x4000))) + (when s5-2 + (let ((t9-14 (method-of-type part-tracker activate))) + (t9-14 + (the-as part-tracker s5-2) + *entity-pool* + (symbol->string (-> part-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-15 run-function-in-process) + (a0-36 s5-2) + (a1-19 part-tracker-init) + (a2-11 (-> *part-group-id-table* 56)) + (a3-7 0) + (t0-6 #f) + (t1-6 #f) + (t2-1 #f) + (t3-0 *launch-matrix*) + ) + (set! (-> t3-0 trans quad) (-> self control trans quad)) + ((the-as (function object object object object object object object object none) t9-15) + a0-36 + a1-19 + a2-11 + a3-7 + t0-6 + t1-6 + t2-1 + t3-0 + ) + ) + (-> s5-2 ppointer) + ) + ) + ) + (('grenade 'explode) + (sound-play "explosion") + (let ((s5-4 (get-process *default-dead-pool* part-tracker #x4000))) + (when s5-4 + (let ((t9-19 (method-of-type part-tracker activate))) + (t9-19 + (the-as part-tracker s5-4) + *entity-pool* + (symbol->string (-> part-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-20 run-function-in-process) + (a0-45 s5-4) + (a1-24 part-tracker-init) + (a2-17 (-> *part-group-id-table* 58)) + (a3-10 0) + (t0-8 #f) + (t1-8 #f) + (t2-3 #f) + (t3-1 *launch-matrix*) + ) + (set! (-> t3-1 trans quad) (-> self control trans quad)) + ((the-as (function object object object object object object object object none) t9-20) + a0-45 + a1-24 + a2-17 + a3-10 + t0-8 + t1-8 + t2-3 + t3-1 + ) + ) + (-> s5-4 ppointer) + ) + ) + ) + (('lava 'melt) + (sound-play "death-melt") + (let ((s5-6 (get-process *default-dead-pool* part-tracker #x4000))) + (when s5-6 + (let ((t9-24 (method-of-type part-tracker activate))) + (t9-24 + (the-as part-tracker s5-6) + *entity-pool* + (symbol->string (-> part-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-25 run-function-in-process) + (a0-52 s5-6) + (a1-29 part-tracker-init) + (a2-23 (-> *part-group-id-table* 57)) + (a3-13 0) + (t0-10 #f) + (t1-10 #f) + (t2-5 #f) + (t3-2 *launch-matrix*) + ) + (set! (-> t3-2 trans quad) (-> self control trans quad)) + ((the-as (function object object object object object object object object none) t9-25) + a0-52 + a1-29 + a2-23 + a3-13 + t0-10 + t1-10 + t2-5 + t3-2 + ) + ) + (-> s5-6 ppointer) + ) + ) + ) + ) + (let ((v1-73 (-> self control root-prim))) + (set! (-> v1-73 prim-core collide-as) (collide-spec)) + (set! (-> v1-73 prim-core collide-with) (collide-spec)) + ) + 0 + (ja-channel-set! 0) + (let ((s5-7 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) s5-7) (seconds 1.8)) + (suspend) + ) + ) + ) + (('endlessfall) + (sound-play "death-fall") + (if (not (-> self pilot as-daxter?)) + (set! (-> self control unknown-sound-id00) + (add-process *gui-control* *target* (gui-channel daxter) (gui-action play) "jakfall" -99.0 0) + ) + ) + (set-falloff! *gui-control* (-> self control unknown-sound-id00) #t -1 100 2) + (logclear! (-> self water flags) (water-flags swim-ground)) + (let ((f0-2 (fmin -4096.0 (- (-> self control ground-impact-vel))))) + (set! (-> self control unknown-word04) (the-as uint f0-2)) + (let ((v1-94 (new-stack-vector0))) + (let ((f1-3 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + 0.0 + (vector-! v1-94 (-> self control transv) (vector-float*! v1-94 (-> self control dynam gravity-normal) f1-3)) + ) + (let* ((f1-4 (vector-length v1-94)) + (f2-1 f1-4) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f0-2) + (vector-float*! v1-94 v1-94 (/ f1-4 f2-1)) + ) + ) + ) + ) + (let ((s5-9 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) s5-9) (seconds 0.5)) + (suspend) + ) + ) + ) + (('bot) + (set! (-> self trans-hook) #f) + (while (not (-> self control unknown-spool-anim00)) + (set-forward-vel 0.0) + (suspend) + ) + ) + (else + ) + ) + (target-death-reset arg0 #f) + (none) + ) + :post target-pilot-post + ) diff --git a/goal_src/jak2/levels/city/common/target-pilot.gc b/goal_src/jak2/levels/city/common/target-pilot.gc index 6ebf4c8eb8..064d3d7421 100644 --- a/goal_src/jak2/levels/city/common/target-pilot.gc +++ b/goal_src/jak2/levels/city/common/target-pilot.gc @@ -5,5 +5,480 @@ ;; name in dgo: target-pilot ;; dgos: CWI +(deftype collide-query-with-5vec (structure) + "A custom type" + ((cquery collide-query :inline) + (vec vector 5 :inline) + ) + ) + ;; DECOMP BEGINS +(define *pilot-mods* (new 'static 'surface :name 'empty :seek0 1.0 :seek90 1.0 :seek180 1.0 :fric 1.0)) + +;; WARN: Return type mismatch none vs object. +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 59] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 64] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 82] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 130] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 150] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 182] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 96] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 114] +;; WARN: disable def twice: 124. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 47] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 9] +(defbehavior target-pilot-handler target ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (the-as + object + (cond + ((and (= arg2 'query) (= (-> arg3 param 0) 'mode)) + 'pilot + ) + (else + (case arg2 + (('end-mode) + (let ((v1-4 (-> self pilot))) + (when (nonzero? v1-4) + (let ((a0-5 (handle->process (-> v1-4 vehicle)))) + (if a0-5 + (put-rider-in-seat (the-as vehicle a0-5) (-> v1-4 seat-index) (the-as process-focusable #f)) + ) + ) + ) + ) + enter-state + (process->handle arg0) + (go target-pilot-get-off) + ) + (('change-mode) + (case (-> arg3 param 0) + (('grab) + (when (not (logtest? (-> self focus-status) (focus-status dead))) + (if (not (-> arg3 param 1)) + #t + (go target-pilot-grab) + ) + ) + ) + (('normal) + enter-state + (process->handle arg0) + (go target-pilot-get-off) + ) + (('gun) + (if (logtest? (-> self game features) (game-feature gun)) + (target-gun-init (the-as int (-> arg3 param 2))) + ) + ) + ) + ) + (('swim) + #f + ) + (('clone-anim) + (go target-pilot-clone-anim (process->handle (the-as process (-> arg3 param 0)))) + ) + (('get-vehicle) + (if (nonzero? (-> self pilot)) + (handle->process (-> self pilot vehicle)) + ) + ) + (('attack 'attack-or-shove 'attack-invinc) + (target-attacked + arg2 + (the-as attack-info (-> arg3 param 1)) + arg0 + (the-as touching-shapes-entry (-> arg3 param 0)) + target-pilot-hit + ) + ) + (('vehicle-hit) + (speech-control-method-12 *speech-control* self (if (-> self pilot as-daxter?) + (speech-type speech-type-1 speech-type-3 speech-type-5) + (speech-type speech-type-0 speech-type-5) + ) + ) + ) + (('vehicle-got-hit) + (speech-control-method-12 + *speech-control* + self + (if (-> self pilot as-daxter?) + (speech-type speech-type-0 speech-type-1 speech-type-3 speech-type-5) + (speech-type speech-type-1 speech-type-5) + ) + ) + ) + (else + (target-standard-event-handler arg0 arg1 arg2 arg3) + ) + ) + ) + ) + ) + ) + +(defbehavior target-pilot-pidax-enter target () + (set! (-> self pilot art-group-backup) (-> self draw art-group)) + (set! (-> self draw art-group) (-> self sidekick 0 draw art-group)) + (logior! (-> self draw status) (draw-control-status no-draw-bounds2)) + (send-event (ppointer->process (-> self sidekick)) 'matrix 'indax) + ) + +(defbehavior target-pilot-pidax-exit target () + (ja-channel-set! 0) + (set! (-> self draw art-group) (the-as art-group (-> self pilot art-group-backup))) + (logclear! (-> self draw status) (draw-control-status no-draw-bounds2)) + (send-event (ppointer->process (-> self sidekick)) 'matrix #f) + ) + +;; WARN: Return type mismatch none vs object. +(defbehavior target-pilot-exit target () + (the-as + object + (when (not (and (-> self next-state) (let ((v1-3 (-> self next-state name))) + (or (= v1-3 'target-pilot-stance) + (= v1-3 'target-pilot-impact) + (= v1-3 'target-pilot-get-off) + (= v1-3 'target-pilot-grab) + (= v1-3 'target-pilot-clone-anim) + (= v1-3 'target-pilot-hit) + (= v1-3 'target-pilot-death) + ) + ) + ) + ) + (let ((v1-4 (-> self manipy))) + (when v1-4 + (deactivate (-> v1-4 0)) + (set! (-> self manipy) (the-as (pointer manipy) #f)) + ) + ) + (if (-> self pilot as-daxter?) + (target-pilot-pidax-exit) + ) + (let ((v1-11 (-> self pilot))) + (when (nonzero? v1-11) + (set! (-> self control nav-radius) (-> v1-11 backup-nav-radius)) + (let ((gp-0 (handle->process (-> v1-11 vehicle)))) + (when gp-0 + (remove-rider (the-as vehicle gp-0) self) + (send-event gp-0 'player-get-off) + ) + ) + ) + ) + (set! (-> self neck flex-blend) 1.0) + (let ((v1-22 (-> self control root-prim))) + (set! (-> v1-22 prim-core collide-as) (-> self control backup-collide-as)) + (set! (-> v1-22 prim-core collide-with) (-> self control backup-collide-with)) + ) + (logclear! (-> self focus-status) (focus-status pilot-riding pilot)) + (logclear! (-> self control root-prim prim-core action) (collide-action stuck-wall-escape)) + (set! (-> self control mod-surface) *walk-mods*) + (logclear! (-> self state-flags) (state-flags sf6)) + (enable-set! (-> self arm-ik 0) #f) + (enable-set! (-> self arm-ik 1) #f) + (set! (-> self control dynam gravity-max) (-> self control standard-dynamics gravity-max)) + (set! (-> self control dynam gravity-length) (-> self control standard-dynamics gravity-length)) + (let ((v1-43 (-> self node-list data))) + (set! (-> v1-43 0 param0) (the-as (function cspace transformq none) cspace<-transformq+trans!)) + (set! (-> v1-43 0 param1) (the-as basic (-> self control trans))) + (set! (-> v1-43 0 param2) (the-as basic (-> self control cspace-offset))) + ) + (target-collide-set! 'normal 0.0) + (set! (-> self control reaction) target-collision-reaction) + (set! (-> self control cspace-offset quad) (the-as uint128 0)) + (target-exit) + ) + ) + ) + +;; WARN: Return type mismatch int vs object. +(defbehavior target-pilot-init target ((arg0 handle) (arg1 symbol)) + (target-exit) + (if (zero? (-> self pilot)) + (set! (-> self pilot) (new 'process 'pilot-info)) + ) + (let ((s5-0 (-> self pilot))) + (set! (-> s5-0 backup-nav-radius) (-> self control nav-radius)) + (set! (-> s5-0 gun?) #t) + (set! (-> s5-0 enable-cam-side-shift) #f) + (set! (-> s5-0 as-daxter?) arg1) + (set! (-> s5-0 entity) #f) + (set! (-> s5-0 cam-side-shift) 0.0) + (if (-> self pilot as-daxter?) + (target-pilot-pidax-enter) + ) + (cond + ((handle->process arg0) + (set! (-> s5-0 vehicle) arg0) + ) + (else + (break!) + 0 + ) + ) + (let ((s4-1 (handle->process (-> s5-0 vehicle)))) + (when s4-1 + (set! (-> s5-0 entity) (-> s4-1 entity)) + (set! (-> s5-0 gun?) (logtest? (-> (the-as vehicle s4-1) info-override flags) 32)) + (set! (-> s5-0 enable-cam-side-shift) (logtest? (-> (the-as vehicle s4-1) info-override flags) 128)) + (send-event + (ppointer->process (-> (the-as vehicle s4-1) parent)) + 'player-got-on-vehicle-child + (the-as vehicle s4-1) + ) + (set! (-> s5-0 stance) (vehicle-method-72 (the-as vehicle s4-1))) + (let ((s3-0 (get-seat-count (the-as vehicle s4-1)))) + (dotimes (s2-0 s3-0) + (let ((a0-20 (get-rider-in-seat (the-as vehicle s4-1) s2-0))) + (if (and a0-20 (send-event a0-20 'knocked-off)) + (put-rider-in-seat (the-as vehicle s4-1) s2-0 (the-as process-focusable #f)) + ) + ) + ) + ) + (let ((v1-43 (get-best-seat-for-vehicle (the-as vehicle s4-1) (-> self control trans) 1 1))) + (set! (-> s5-0 seat-index) (max 0 v1-43)) + ) + (cond + ((-> s5-0 as-daxter?) + (set! (-> s5-0 left-right-accel-factor) 0.0000012207031) + (set! (-> s5-0 front-back-accel-factor) 0.0000012207031) + (set! (-> s5-0 up-down-accel-factor) 0.0000012207031) + ) + ((zero? (-> s5-0 stance)) + (set! (-> s5-0 left-right-accel-factor) 0.0000012207031) + (set! (-> s5-0 front-back-accel-factor) 0.0000012207031) + (set! (-> s5-0 up-down-accel-factor) 0.00000051879886) + ) + (else + (set! (-> s5-0 left-right-accel-factor) 0.0000012207031) + (set! (-> s5-0 front-back-accel-factor) 0.0000012207031) + (set! (-> s5-0 up-down-accel-factor) 0.00000061035155) + ) + ) + ) + ) + (when (not (-> s5-0 gun?)) + (if arg1 + (set! (-> self control current-surface flags) + (logior (surface-flag gun-fast-exit) (-> self control current-surface flags)) + ) + ) + (target-gun-end-mode arg1) + ) + ) + (set! (-> self board latch?) #f) + (set! (-> self control reaction) target-collision-reaction) + (set! (-> self control transv quad) (the-as uint128 0)) + (set! (-> self control ctrl-xz-vel) 0.0) + (set! (-> self focus-status) (logior (focus-status pilot) (-> self focus-status))) + (set! (-> self control bend-target) 0.0) + (let ((v1-73 (-> self node-list data))) + (set! (-> v1-73 0 param0) (the-as (function cspace transformq none) cspace<-transformq+world-trans!)) + (set! (-> v1-73 0 param1) (the-as basic (-> self control trans))) + (set! (-> v1-73 0 param2) (the-as basic (-> self control cspace-offset))) + ) + (let ((v1-75 (-> self control root-prim))) + (set! (-> v1-75 prim-core collide-as) (collide-spec)) + (set! (-> v1-75 prim-core collide-with) (collide-spec)) + ) + 0 + (set! (-> self control root-prim prim-core collide-as) (collide-spec jak-vehicle)) + (set! (-> self neck flex-blend) 0.0) + (set! (-> self control status) (collide-status)) + (the-as object 0) + ) + +(defbehavior pilot-on-ground? target () + (logtest? (-> self control status) (collide-status on-surface)) + ) + +(defbehavior target-pilot-post target () + (local-vars (v1-55 symbol) (a0-44 object) (a0-56 int) (a0-58 int)) + (let* ((v1-1 (-> *perf-stats* data 17)) + (a0-0 (-> v1-1 ctrl)) + ) + (+! (-> v1-1 count) 1) + (b! (zero? a0-0) cfg-2 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mtpc pcr0 0) + (.mtpc pcr1 0) + (.sync.l) + (.sync.p) + (.mtc0 Perf a0-0) + ) + (.sync.l) + (.sync.p) + (label cfg-2) + 0 + (let ((f30-0 (-> self clock clock-ratio))) + (let ((gp-1 (max 1 (the int (-> self clock time-adjust-ratio))))) + (update-rates! (-> self clock) (/ f30-0 (the float gp-1))) + (b! #t cfg-4 :delay (nop!)) + (label cfg-3) + (+! gp-1 -1) + (set! (-> self control remaining-ctrl-iterations) gp-1) + (flag-setup) + (build-conversions (-> self control transv)) + (do-rotations1) + (do-rotations2) + (reverse-conversions (-> self control transv)) + (vector-! + (-> self control cspace-offset) + (-> self control draw-offset) + (-> self control anim-collide-offset-world) + ) + (let ((a1-5 (new 'stack-no-clear 'overlaps-others-params))) + (set! (-> a1-5 options) (overlaps-others-options oo0)) + (set! (-> a1-5 collide-with-filter) (the-as collide-spec -1)) + (set! (-> a1-5 tlist) *touching-list*) + (find-overlapping-shapes (-> self control) a1-5) + ) + (post-flag-setup) + (label cfg-4) + (b! (nonzero? gp-1) cfg-3 :delay (nop!)) + ) + (update-rates! (-> self clock) f30-0) + ) + (let* ((gp-2 (-> self pilot)) + (s5-0 (handle->process (-> gp-2 vehicle))) + ) + (when s5-0 + (compute-seat-position (the-as vehicle s5-0) (-> self control trans) (-> gp-2 seat-index)) + (set! (-> self control transv quad) (-> (the-as vehicle s5-0) root-override-2 transv quad)) + (quaternion-copy! (-> self control quat) (-> (the-as vehicle s5-0) root-override-2 quat)) + (quaternion-copy! (-> self control quat-for-control) (-> self control quat)) + (quaternion-copy! (-> self control dir-targ) (-> self control quat)) + (let ((s4-0 (-> self alt-cam-pos))) + (when (not (logtest? (-> self focus-status) (focus-status dead))) + (let ((s3-0 (new 'stack-no-clear 'collide-query-with-5vec))) + (set! (-> s3-0 vec 2 x) 0.0) + (set! (-> s3-0 vec 2 y) 20480.0) + (let ((a0-18 (-> self node-list data 0 bone transform))) + (set! (-> s3-0 vec 1 quad) (-> a0-18 vector 2 quad)) + ) + (set! (-> s3-0 vec 1 y) 0.0) + (vector-rotate90-around-y! (-> s3-0 vec 1) (-> s3-0 vec 1)) + (vector-normalize! (-> s3-0 vec 1) 1.0) + (set! (-> s3-0 vec 0 quad) (-> self control trans quad)) + (when (-> gp-2 enable-cam-side-shift) + (let ((s2-0 0)) + (b! #t cfg-22 :delay (nop!)) + (label cfg-14) + (let ((v1-48 (-> s3-0 cquery))) + (set! (-> v1-48 radius) 2048.0) + (set! (-> v1-48 collide-with) (collide-spec backgnd)) + (set! (-> v1-48 ignore-process0) #f) + (set! (-> v1-48 ignore-process1) #f) + (set! (-> v1-48 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-48 action-mask) (collide-action solid)) + ) + (set! (-> s3-0 cquery start-pos quad) (-> s3-0 vec 0 quad)) + (vector-float*! (-> s3-0 cquery move-dist) (-> s3-0 vec 1) (-> s3-0 vec 2 y)) + (let ((f0-10 (fill-and-probe-using-line-sphere *collide-cache* (-> s3-0 cquery)))) + (let ((v1-54 (>= f0-10 0.0))) + (b! (not v1-54) cfg-19 :likely-delay (set! v1-55 v1-54)) + ) + (set! v1-55 (= (-> s3-0 cquery best-other-tri pat mode) (pat-mode wall))) + (label cfg-19) + (when v1-55 + (+! (-> s3-0 vec 2 x) (* -1.0 (-> s3-0 vec 2 y) (- 1.0 f0-10))) + 0 + ) + ) + (set! (-> s3-0 vec 2 y) (* -1.0 (-> s3-0 vec 2 y))) + (+! s2-0 1) + (label cfg-22) + (b! (< s2-0 2) cfg-14) + ) + (set! (-> s3-0 vec 2 x) + (* (-> s3-0 vec 2 x) (fmax 0.25 (fmin 1.0 (* 0.000008138021 (vector-length (-> self control transv)))))) + ) + (seek! (-> gp-2 cam-side-shift) (-> s3-0 vec 2 x) (* 16384.0 (-> self clock seconds-per-frame))) + ) + (set! (-> s4-0 x) (+ (-> s3-0 vec 0 x) (* (-> gp-2 cam-side-shift) (-> s3-0 vec 1 x)))) + (set! (-> s4-0 z) (+ (-> s3-0 vec 0 z) (* (-> gp-2 cam-side-shift) (-> s3-0 vec 1 z)))) + (set! (-> s4-0 y) (fmax (fmin (-> s4-0 y) (+ 2048.0 (-> s3-0 vec 0 y))) (+ -2048.0 (-> s3-0 vec 0 y)))) + ) + 0 + ) + ) + (let ((s4-1 (new 'stack-no-clear 'matrix))) + (vehicle-method-117 (the-as vehicle s5-0) (the-as vector (-> s4-1 vector)) (-> gp-2 seat-index) 0) + (vehicle-method-117 (the-as vehicle s5-0) (-> s4-1 vector 1) (-> gp-2 seat-index) 1) + (enable-set! (-> self arm-ik 0) #t) + (enable-set! (-> self arm-ik 1) #t) + (handle-copy! (-> self arm-ik 0) (the-as vector (-> s4-1 vector))) + (handle-copy! (-> self arm-ik 1) (-> s4-1 vector 1)) + ) + ) + ) + (when *debug-segment* + (let ((gp-3 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-97 'target-post) + (s5-1 *profile-target-post-color*) + ) + (let ((a0-43 *dproc*)) + (b! (not a0-43) cfg-30 :likely-delay (set! a0-44 a0-43)) + ) + (set! a0-44 *debug-segment*) + (label cfg-30) + (when a0-44 + (let ((s4-2 (-> gp-3 data (-> gp-3 count)))) + (let ((s3-1 (-> gp-3 base-time))) + (set! (-> s4-2 name) v1-97) + (set! (-> s4-2 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-1)))) + ) + (set! (-> s4-2 depth) (the-as uint (-> gp-3 depth))) + (set! (-> s4-2 color) s5-1) + (set! (-> gp-3 segment (-> gp-3 depth)) s4-2) + ) + (+! (-> gp-3 count) 1) + (+! (-> gp-3 depth) 1) + (set! (-> gp-3 max-depth) (max (-> gp-3 max-depth) (-> gp-3 depth))) + ) + ) + 0 + ) + (ja-post) + (when *debug-segment* + (let ((gp-4 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-121 (+ (-> gp-4 depth) -1)) + (s5-2 (-> gp-4 segment v1-121)) + (s4-3 (-> gp-4 base-time)) + ) + (when (>= v1-121 0) + (set! (-> s5-2 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-3)))) + (+! (-> gp-4 depth) -1) + ) + ) + ) + ) + 0 + ) + (joint-points) + (update-transforms (-> self control)) + (do-target-gspot) + (target-powerup-process) + (let ((v1-130 (-> *perf-stats* data 17))) + (b! (zero? (-> v1-130 ctrl)) cfg-43 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mfpc a0-56 pcr0) + (+! (-> v1-130 accum0) a0-56) + (.mfpc a0-58 pcr1) + (+! (-> v1-130 accum1) a0-58) + ) + (label cfg-43) + 0 + 0 + (none) + ) diff --git a/goal_src/jak2/levels/city/common/test-bike.gc b/goal_src/jak2/levels/city/common/test-bike.gc index 664b25d3c2..c4657c31c3 100644 --- a/goal_src/jak2/levels/city/common/test-bike.gc +++ b/goal_src/jak2/levels/city/common/test-bike.gc @@ -7,3 +7,472 @@ ;; DECOMP BEGINS +(deftype test-bike (bikec) + () + :heap-base #x320 + :method-count-assert 144 + :size-assert #x39c + :flag-assert #x900320039c + ) + + +(define *test-bike-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 2.0 + :inv-mass 0.5 + :linear-damping 0.995 + :angular-damping 0.995 + :friction-factor 0.516 + :cm-offset-joint (new 'static 'vector :z 2457.6 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 1.5) (meters 2) (meters 5)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*test-bike-constants* + :flags #x11 + :object-type #xd + :guard-type #x7 + :max-engine-thrust (meters 50) + :inv-max-engine-thrust 0.0000048828124 + :engine-response-rate 32.0 + :engine-intake-factor 1.0 + :brake-factor 2.0 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 100) + :ground-probe-distance (meters 5) + :ground-probe-offset (meters 0.5) + :cos-ground-effect-angle -0.00000004371139 + :spring-lift-factor 0.35 + :air-drag-factor 1.2 + :steering-fin-angle 1820.4445 + :steering-thruster-factor 6.0 + :steering-thruster-max-gain 2.0 + :steering-thruster-half-gain-speed (meters 80) + :tire-steering-angle 1274.3112 + :tire-static-friction 0.5 + :tire-static-friction-speed (meters 1) + :tire-dynamic-friction 0.25 + :tire-dynamic-friction-speed (meters 3) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 8.0 + :drag-force-factor 1.0 + :speed-limiting-drag 0.75 + :pitch-control-factor 0.5 + :roll-control-factor 1.0 + :roll-angle 7281.778 + :jump-thrust-factor 0.625 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 0.125) + :target-speed-offset (meters 4) + :turning-accel (meters 20) + :toughness-factor 1.0 + :damage-factor 4.0 + :camera-string-min-height (meters 2.5) + :camera-string-max-height (meters 2.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 5.5) + :camera-min-fov 16384.0 + :camera-max-fov 18204.445 + :camera-head-offset 4096.0 + :camera-foot-offset -4096.0 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 2 + :section-count 2 + :grab-rail-count 2 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 2 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x 2048.0 :z 8192.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -2048.0 :z 8192.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 802.816 :z 1318.912 :w (the-as float #x10000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 2048.0 :z -4096.0 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 409.6 :z 4710.4 :w 1.0) + (new 'static 'vector :x -2457.6 :y 409.6 :z 4710.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x20 #x8 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x40 #x10 #x4) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-offset -0.25 + :engine-pitch-mod-amp 0.05 + :engine-sound-select 2 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "bike-scrape-stn") + :glance-sound (static-sound-name "bike-glance-stn") + :impact-sound (static-sound-name "bike-impact-stn") + :extra-sound (static-sound-name "car-by-1") + :explosion-part #xa1 + :headlight-count 1 + :taillight-count 1 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :z -3276.8 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :y 204.8 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :y 204.8 :z -3276.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1638.4 :y -2048.0 :z 7372.8 :w 1.0) + (new 'static 'vector :x -1638.4 :y -2048.0 :z 7372.8 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 (new 'static 'vector :w 1.0) (new 'static 'vector :w 1.0)) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :y -614.4 :z 13721.6 :w 1.0) + (new 'static 'vector) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 (new 'static 'vector :y 614.4 :z -7168.0 :w 1.0) (new 'static 'vector)) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 7372.8003 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -2457.6 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10240.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5324.8 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10649.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.25) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.75) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 0.25) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :brake-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :color-option-count 1 + :color-option-array (new 'static 'inline-array vector 1 (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0)) + ) + ) + +(defmethod init-skel-and-rigid-body test-bike ((obj test-bike)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-bikec" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *test-bike-constants*) + (set! (-> obj fin-fl) (new 'process 'joint-mod-rotate-local obj 7 #t)) + (set! (-> obj fin-fr) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 9 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 10 #t)) + (set! (-> obj fin2-fl) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj fin2-fr) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj rudder) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj brake-l) (new 'process 'joint-mod-rotate-local obj 11 #t)) + (set! (-> obj brake-r) (new 'process 'joint-mod-rotate-local obj 12 #t)) + (set! (-> obj spoiler-l) (new 'process 'joint-mod-rotate-local obj 13 #t)) + (set! (-> obj spoiler-r) (new 'process 'joint-mod-rotate-local obj 14 #t)) + 0 + (none) + ) + +(deftype evan-test-bike (bikea) + () + :heap-base #x310 + :method-count-assert 144 + :size-assert #x38c + :flag-assert #x900310038c + ) + + +(define *evan-test-bike-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 2.0 + :inv-mass 0.5 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :z 2457.6 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 3) (meters 4) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*evan-test-bike-constants* + :flags #x70 + :object-type #xb + :guard-type #x7 + :max-engine-thrust (meters 50) + :inv-max-engine-thrust 0.0000048828124 + :engine-response-rate 30.0 + :engine-intake-factor 1.0 + :brake-factor 2.0 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.3 + :air-drag-factor 1.0 + :steering-thruster-factor 5.0 + :steering-thruster-max-gain 4.0 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.5 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.75 + :pitch-control-factor 1.0 + :roll-control-factor 1.0 + :jump-thrust-factor 0.625 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 4) + :turning-accel (meters 20) + :toughness-factor 1.0 + :damage-factor 4.0 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 5461.3335 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 2 + :section-count 2 + :grab-rail-count 2 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 2 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x 2048.0 :z 4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -2048.0 :z 4096.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info :position (new 'static 'vector :w (the-as float #x10000))) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 2048.0 :z -4096.0 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 409.6 :z 4710.4 :w 1.0) + (new 'static 'vector :x -2457.6 :y 409.6 :z 4710.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x10 #x8 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x20 #x4 #x0) + :damage-seg-count 2 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-offset -0.25 + :engine-pitch-mod-amp 0.05 + :engine-sound-select 1 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "bike-scrape-stn") + :glance-sound (static-sound-name "bike-glance-stn") + :impact-sound (static-sound-name "bike-impact-stn") + :extra-sound (static-sound-name "bike-by-1") + :explosion-part #xa1 + :headlight-count 1 + :taillight-count 1 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :z -3276.8 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :y 204.8 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :y 204.8 :z -3276.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1638.4 :y -2048.0 :z 7372.8 :w 1.0) + (new 'static 'vector :x -1638.4 :y -2048.0 :z 7372.8 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 (new 'static 'vector :w 1.0) (new 'static 'vector :w 1.0)) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :y -819.2 :z 10240.0 :w 1.0) + (new 'static 'vector) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 (new 'static 'vector :y 1433.6 :z -10240.0 :w 1.0) (new 'static 'vector)) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z 7372.8003 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z -2457.6 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10240.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5324.8 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10649.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :brake-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :color-option-count 1 + :color-option-array (new 'static 'inline-array vector 1 (new 'static 'vector :x 0.6 :y 0.6 :z 1.5 :w 1.0)) + ) + ) + +(defmethod init-skel-and-rigid-body evan-test-bike ((obj evan-test-bike)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-bikea" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *evan-test-bike-constants*) + (set! (-> obj fin-fl) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj fin-fr) (new 'process 'joint-mod-rotate-local obj 7 #t)) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj rudder) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj brake-l) (new 'process 'joint-mod-rotate-local obj 9 #t)) + (set! (-> obj brake-r) (new 'process 'joint-mod-rotate-local obj 10 #t)) + 0 + (none) + ) diff --git a/goal_src/jak2/levels/city/common/test-car.gc b/goal_src/jak2/levels/city/common/test-car.gc index dcc1f44443..44ee9ea082 100644 --- a/goal_src/jak2/levels/city/common/test-car.gc +++ b/goal_src/jak2/levels/city/common/test-car.gc @@ -7,3 +7,284 @@ ;; DECOMP BEGINS +(deftype test-car (cara) + () + :heap-base #x320 + :method-count-assert 144 + :size-assert #x398 + :flag-assert #x9003200398 + ) + + +(define *test-car-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 8.0 + :inv-mass 0.125 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 4) (meters 3) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*test-car-constants* + :flags #x68 + :object-type #xe + :guard-type #x7 + :max-engine-thrust (meters 39) + :inv-max-engine-thrust 0.000006260016 + :engine-response-rate 20.0 + :engine-intake-factor 1.0 + :brake-factor 1.0 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 4.5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.4 + :air-drag-factor 1.0 + :steering-thruster-factor 3.0 + :steering-thruster-max-gain 3.5 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.6 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.7 + :pitch-control-factor 0.5 + :roll-control-factor 1.0 + :jump-thrust-factor 0.5 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 3) + :turning-accel (meters 20) + :toughness-factor 1.0 + :damage-factor 2.5 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 5461.3335 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 3 + :section-count 4 + :rider-stance #x1 + :grab-rail-count #x6 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 6 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 4505.6 :y -2662.4 :z 15360.0 :w 1.0) + (new 'static 'vector :x -4505.6 :y -2662.4 :z 15360.0 :w 1.0) + ) + :normal (new 'static 'vector :z 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 7372.8 :y -819.2 :z -4096.0 :w 1.0) + (new 'static 'vector :x 7372.8 :y -819.2 :z 4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -7372.8 :y -819.2 :z 4096.0 :w 1.0) + (new 'static 'vector :x -7372.8 :y -819.2 :z -4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -3686.4 :y -409.6 :z -14950.4 :w 1.0) + (new 'static 'vector :x 3686.4 :y -409.6 :z -14950.4 :w 1.0) + ) + :normal (new 'static 'vector :z -1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3837.952 :y -409.6 :z -14950.4 :w 1.0) + (new 'static 'vector :x 6041.6 :y -614.4 :z -9011.2 :w 1.0) + ) + :normal (new 'static 'vector :x 0.707 :z -0.707 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -6041.6 :y -614.4 :z -9011.2 :w 1.0) + (new 'static 'vector :x -3837.952 :y -409.6 :z -14950.4 :w 1.0) + ) + :normal (new 'static 'vector :x -0.707 :z -0.707 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :x 4079.616 :y 819.2 :z -311.296 :w (the-as float #x30000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :x -4079.616 :y 819.2 :z -311.296 :w (the-as float #x30000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 3751.936 :z -10563.584 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 614.4 :y 614.4 :z 1433.6 :w 1.0) + (new 'static 'vector :x 614.4 :y 614.4 :z -1433.6 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x200 #x20 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x400 #x40 #x4) + :damage-seg-count 3 + ) + :section-car-front-right (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x800 #x80 #x8) + :damage-seg-count 3 + ) + :section-car-rear-right (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x1000 #x100 #x10) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.09 + :engine-pitch-mod-amp 0.01 + :engine-sound-select 5 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "car-scrape-stn") + :glance-sound (static-sound-name "car-glance-stn") + :impact-sound (static-sound-name "car-impact-stn") + :extra-sound (static-sound-name "car-by-5") + :explosion-part #xa1 + :headlight-count 2 + :taillight-count 2 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3072.0 :z -14336.0 :w 1.0) + (new 'static 'vector :x -3072.0 :z -14336.0 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 6963.2 :y -1024.0 :z -7372.8 :w 1.0) + (new 'static 'vector :x -6963.2 :y -1024.0 :z -7372.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3072.0 :z -13926.4 :w 1.0) + (new 'static 'vector :x -3072.0 :z -13926.4 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 + (new 'static 'vector :x 12288.0 :w 1.0) + (new 'static 'vector :x -12288.0 :w 1.0) + ) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :x 4915.2 :z 15564.8 :w 1.0) + (new 'static 'vector :x -4915.2 :z 15564.8 :w 1.0) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3276.8 :y 3276.8 :z -14131.2 :w 1.0) + (new 'static 'vector :x -3276.8 :y 3276.8 :z -14131.2 :w 1.0) + ) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z 8192.0 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z -8192.0 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 7782.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -7782.4 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -8192.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 8192.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -8192.0 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :brake-local-pos (new 'static 'vector :z -8192.0 :w 1.0) + :color-option-count 1 + :color-option-array (new 'static 'inline-array vector 1 (new 'static 'vector :x 0.5 :y 1.0 :z 0.5 :w 1.0)) + ) + ) + +(defmethod init-skel-and-rigid-body test-car ((obj test-car)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-cara" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *test-car-constants*) + (set! (-> obj rider-hand-joint-array 0) 11) + (set! (-> obj rider-hand-joint-array 1) 12) + (set! (-> obj steering-wheel-l) (new 'process 'joint-mod-rotate-local obj 11 #t)) + (set! (-> obj steering-wheel-r) (new 'process 'joint-mod-rotate-local obj 12 #t)) + (set! (-> obj fin-fl) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj fin-fr) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj rudder) (new 'process 'joint-mod-rotate-local obj 10 #t)) + (set! (-> obj rudder-l) (new 'process 'joint-mod-rotate-local obj 7 #t)) + (set! (-> obj rudder-r) (new 'process 'joint-mod-rotate-local obj 9 #t)) + 0 + (none) + ) diff --git a/goal_src/jak2/levels/city/common/traffic-engine-h.gc b/goal_src/jak2/levels/city/common/traffic-engine-h.gc index 5db56ebf16..aa45c4959f 100644 --- a/goal_src/jak2/levels/city/common/traffic-engine-h.gc +++ b/goal_src/jak2/levels/city/common/traffic-engine-h.gc @@ -42,6 +42,33 @@ ) ;; ---traffic-alert-flag +(defenum traffic-suppression-box-flags + :type uint8 + :bitfield #t + (in-use 0) + (tfsb1 1) + (tfsb2 2) + (tfsb3 3) + (tfsb4 4) + (tfsb5 5) + (tfsb6 6) + (tfsb7 7) + ) + +(defenum traffic-suppression-flags + :type uint8 + :bitfield #t + (tfs0 0) + (needs-update 1) + (tfs2 2) + (tfs3 3) + (tfs4 4) + (tfs5 5) + (tfs6 6) + (tfs7 7) + ) + + (declare-type traffic-find-segment-struct structure) ;; DECOMP BEGINS @@ -80,8 +107,8 @@ :size-assert #x20 :flag-assert #xb00000020 (:methods - (vis-cell-method-9 (_type_) none 9) - (vis-cell-method-10 (_type_) none 10) + (reset-segment-counts (_type_) none 9) + (debug-draw (_type_) none 10) ) ) @@ -135,38 +162,38 @@ :size-assert #x40 :flag-assert #xe00000040 (:methods - (grid-info-method-9 (_type_ (pointer bounding-box) int int) none 9) - (grid-info-method-10 (_type_ vis-grid-pos vector) none 10) - (grid-info-method-11 (_type_ vis-grid-box vector) none 11) - (grid-info-method-12 (_type_ rgba) none 12) - (grid-info-method-13 (_type_ vis-grid-pos rgba) none 13) + (setup-grid-from-bounding-box (_type_ (pointer bounding-box) int int) none 9) + (lookup-cell-for-point (_type_ vis-grid-pos vector) none 10) + (lookup-box-for-sphere (_type_ vis-grid-box vector) none 11) + (debug-draw-grid (_type_ rgba) none 12) + (debug-draw-cell (_type_ vis-grid-pos rgba) none 13) ) ) (deftype city-level-info (structure) - ((grid-info grid-info :inline :offset-assert 0) - (cell-array (inline-array vis-cell) :offset-assert 64) - (segment-count int16 :offset-assert 68) - (cell-count uint16 :offset-assert 70) - (segment-array uint32 :offset-assert 72) - (nav-graph nav-graph :offset-assert 76) - (camera-ceiling meters :offset-assert 80) - (pad-array int8 56 :offset-assert 84) + ((grid-info grid-info :inline :offset-assert 0) + (cell-array (inline-array vis-cell) :offset-assert 64) + (segment-count int16 :offset-assert 68) + (cell-count uint16 :offset-assert 70) + (segment-array (inline-array nav-segment) :offset-assert 72) + (nav-graph nav-graph :offset-assert 76) + (camera-ceiling meters :offset-assert 80) + (pad-array int8 56 :offset-assert 84) ) :method-count-assert 19 :size-assert #x8c :flag-assert #x130000008c (:methods (city-level-info-method-9 (_type_) symbol 9) - (city-level-info-method-10 (_type_ vis-ray vector vector) none 10) + (init-vis-ray (_type_ vis-ray vector vector) none 10) (city-level-info-method-11 (_type_ vis-ray) none 11) (city-level-info-method-12 (_type_ vector nav-branch vector) vector 12) - (city-level-info-method-13 (_type_ vector) none 13) - (city-level-info-method-14 (_type_ vis-grid-box) vis-cell 14) - (city-level-info-method-15 (_type_ int int) symbol 15) - (city-level-info-method-16 (_type_ vector int traffic-find-segment-struct (function traffic-find-segment-struct object none)) none 16) - (city-level-info-method-17 (_type_ traffic-engine) none 17) + (lookup-cell-by-position (_type_ vector) vis-cell 13) + (get-first-cell-in-box (_type_ vis-grid-box) vis-cell 14) + (sphere-in-grid? (_type_ int int) symbol 15) + (callback-on-nav-segments-in-sphere (_type_ vector int traffic-find-segment-struct (function traffic-find-segment-struct nav-segment none)) none 16) + (update-suppressions-from-traffic-engine (_type_ traffic-engine) none 17) (city-level-info-method-18 (_type_) none 18) ) ) @@ -184,21 +211,21 @@ :size-assert #x820 :flag-assert #xf00000820 (:methods - (traffic-level-data-method-9 (_type_) none 9) - (traffic-level-data-method-10 (_type_ vis-cell) none 10) - (traffic-level-data-method-11 (_type_ int) none 11) - (traffic-level-data-method-12 (_type_ vis-cell) none 12) - (traffic-level-data-method-13 (_type_) vis-cell 13) - (traffic-level-data-method-14 (_type_) none 14) + (reset (_type_) none 9) + (add-active-cell (_type_ vis-cell) none 10) + (remove-active-cell (_type_ int) none 11) + (add-newly-active-cell (_type_ vis-cell) none 12) + (per-frame-cell-update (_type_) none 13) + (debug-draw (_type_) none 14) ) ) (deftype traffic-suppression-box (structure) - ((data uint8 32 :offset-assert 0) - (bbox bounding-box :inline :offset 0) - (flags uint8 :offset 12) - (duration uint32 :offset 28) + ((data uint8 32 :offset-assert 0) + (bbox bounding-box :inline :offset 0) + (flags traffic-suppression-box-flags :offset 12) + (duration uint32 :offset 28) ) :method-count-assert 9 :size-assert #x20 @@ -207,12 +234,12 @@ (deftype traffic-guard-type-info (structure) - ((object-type uint8 :offset-assert 0) - (max-target-count int8 :offset-assert 1) - (min-target-count int8 :offset-assert 2) - (target-count int8 :offset-assert 3) - (count int8 :offset-assert 4) - (change-to-type uint8 :offset-assert 5) + ((object-type traffic-type :offset-assert 0) + (max-target-count int8 :offset-assert 1) + (min-target-count int8 :offset-assert 2) + (target-count int8 :offset-assert 3) + (count int8 :offset-assert 4) + (change-to-type uint8 :offset-assert 5) ) :method-count-assert 9 :size-assert #x6 @@ -275,7 +302,7 @@ (duration uint32 :offset-assert 16) (start-time time-frame :offset-assert 24) (notify-time time-frame :offset-assert 32) - (alarm-sound-id uint32 :offset-assert 40) + (alarm-sound-id sound-id :offset-assert 40) (target-status-array traffic-target-status 3 :inline :offset-assert 48) (settings traffic-alert-state-settings :inline :offset-assert 288) (guard-type-info-array traffic-guard-type-info 6 :inline :offset-assert 384) @@ -285,7 +312,7 @@ :size-assert #x3d8 :flag-assert #xa000003d8 (:methods - (traffic-alert-state-method-9 (_type_) none 9) + (reset (_type_) none 9) ) ) @@ -311,19 +338,19 @@ (deftype traffic-suppressor (structure) - ((flags uint8 :offset-assert 0) - (bbox bounding-box :inline :offset-assert 16) - (array traffic-suppression-box 16 :inline :offset-assert 48) + ((flags traffic-suppression-flags :offset-assert 0) + (bbox bounding-box :inline :offset-assert 16) + (array traffic-suppression-box 16 :inline :offset-assert 48) ) :method-count-assert 14 :size-assert #x230 :flag-assert #xe00000230 (:methods - (traffic-suppressor-method-9 (_type_) none 9) - (traffic-suppressor-method-10 (_type_ traffic-suppression-params) none 10) - (traffic-suppressor-method-11 (_type_ int) none 11) - (traffic-suppressor-method-12 (_type_ traffic-suppression-params) none 12) - (traffic-suppressor-method-13 (_type_) none 13) + (reset-boxes (_type_) none 9) + (add-new-supression-box (_type_ traffic-suppression-params) none 10) + (remove-box-by-id (_type_ int) none 11) + (update-box-from-params (_type_ traffic-suppression-params) none 12) + (debug-draw (_type_) none 13) ) ) @@ -336,7 +363,7 @@ (active-object-count uint8 :offset-assert 13) (inactive-object-count int8 :offset-assert 14) (active-object-list handle 126 :offset-assert 16) - (active-object-type-list uint8 126 :offset-assert 1024) + (active-object-type-list traffic-type 126 :offset-assert 1024) ) :method-count-assert 27 :size-assert #x47e @@ -345,28 +372,28 @@ (traffic-tracker-method-9 (_type_) none 9) (traffic-tracker-method-10 (_type_) none 10) (traffic-tracker-method-11 (_type_) none 11) - (traffic-tracker-method-12 (_type_ uint handle) none 12) - (traffic-tracker-method-13 (_type_ int) handle 13) - (traffic-tracker-method-14 (_type_ int handle) none 14) - (traffic-tracker-method-15 (_type_ int) handle 15) - (traffic-tracker-method-16 (_type_ int handle) handle 16) - (traffic-tracker-method-17 (_type_ int handle) none 17) - (traffic-tracker-method-18 (_type_ process) none 18) - (traffic-tracker-method-19 (_type_ handle) none 19) - (traffic-tracker-method-20 (_type_ int symbol) none 20) - (traffic-tracker-method-21 (_type_ traffic-object-spawn-params) none 21) - (traffic-tracker-method-22 (_type_ int nav-segment float) none 22) - (traffic-tracker-method-23 (_type_ traffic-object-spawn-params) none 23) - (traffic-tracker-method-24 (_type_ uint traffic-engine) none 24) - (traffic-tracker-method-25 (_type_ (function process-focusable traffic-object-type-info none)) none 25) - (traffic-tracker-method-26 (_type_ int (function process-tree none)) none 26) + (add-active-process (_type_ traffic-type handle) none 12) + (remove-active-process (_type_ int) handle 13) + (add-reserved-process (_type_ traffic-type handle) none 14) + (get-from-inactive-by-type (_type_ traffic-type) handle 15) + (get-from-inactive-by-handle (_type_ traffic-type handle) handle 16) + (deactivate-object (_type_ int symbol) none 17) + (set-process-to-killed (_type_ process) none 18) + (deactivate-all (_type_ symbol) none 19) + (deactivate-all-of-type (_type_ traffic-type symbol) none 20) + (activate-from-params (_type_ traffic-object-spawn-params) none 21) + (activate-by-type (_type_ traffic-type nav-segment float) none 22) + (activate-by-handle (_type_ traffic-object-spawn-params) none 23) + (reset (_type_ uint traffic-engine) none 24) + (for-all-active-processes (_type_ (function process-focusable traffic-object-type-info none)) none 25) + (for-all-active-processes-of-type (_type_ traffic-type (function process-focusable traffic-object-type-info none)) none 26) ) ) (deftype traffic-engine (basic) ((object-hash spatial-hash :offset-assert 4) - (manager uint64 :offset-assert 8) + (manager handle :offset-assert 8) (inv-density-factor float :offset-assert 16) (sync-clock uint8 :offset-assert 20) (sync-mask-8 uint8 :offset-assert 21) @@ -378,6 +405,8 @@ (level-data-array traffic-level-data 2 :inline :offset-assert 1040) (object-type-info-array traffic-object-type-info 21 :inline :offset-assert 5200) (tracker-array traffic-tracker 2 :inline :offset-assert 5872) + (citizen-tracker-array traffic-tracker :inline :offset 5872) + (vehicle-tracker-array traffic-tracker :inline :offset 7024) (inactive-object-array handle 420 :offset-assert 8176) (suppressor traffic-suppressor :inline :offset-assert 11536) (danger-sphere-count int8 :offset-assert 12096) @@ -388,33 +417,34 @@ :size-assert #x3050 :flag-assert #x4a00003050 (:methods - (traffic-engine-method-9 (_type_) none 9) - (traffic-engine-method-10 (_type_ process) none 10) - (traffic-engine-method-11 (_type_) none 11) - (traffic-engine-method-12 (_type_) none 12) - (add-object (_type_ int process) none 13) - (traffic-engine-method-14 (_type_ object object) symbol 14) - (traffic-engine-method-15 (_type_ nav-segment float) none 15) - (traffic-engine-method-16 (_type_ nav-segment float) none 16) - (traffic-engine-method-17 (_type_ nav-branch) symbol 17) + (new (symbol type) _type_ 0) + (update-traffic (_type_) none 9) + (reset-and-init-from-manager (_type_ process) none 10) + (stop-alarm-sound (_type_) none 11) + (debug-unused (_type_) none 12) + (add-object (_type_ traffic-type process) none 13) + (sphere-in-loaded-city-infos? (_type_ int vector) symbol 14) + (activate-one-citizen (_type_ nav-segment float) none 15) + (activate-one-vehicle (_type_ nav-segment float) none 16) + (can-dest-be-used? (_type_ nav-branch) symbol 17) (child-killed (_type_ process) none 18) - (traffic-engine-method-19 (_type_ object) none 19) - (traffic-engine-method-20 (_type_ vector vector int) nav-segment 20) - (traffic-engine-method-21 (_type_ vector int traffic-find-segment-struct function) none 21) - (add-danger-sphere (_type_ traffic-danger-info) none 22) - (traffic-engine-method-23 (_type_) none 23) + (deactivate-all-from-level (_type_ symbol) none 19) + (find-best-segment (_type_ vector vector int) nav-segment 20) + (callback-on-nav-segments-in-sphere (_type_ vector int traffic-find-segment-struct (function traffic-find-segment-struct nav-segment none)) none 21) + (add-danger (_type_ traffic-danger-info) none 22) + (guard-count (_type_) int 23) (set-target-level (_type_ float) none 24) (set-guard-target-level (_type_ float) none 25) (deactivate-all (_type_) none 26) - (deactivate-by-type (_type_ int) none 27) - (traffic-engine-method-28 (_type_) symbol 28) + (deactivate-by-type (_type_ traffic-type) none 27) + (maybe-increase-guard-aim-count (_type_) symbol 28) (restore-default-settings (_type_) none 29) - (increase-alert-level (_type_ object target) none 30) - (decrease-alert-level (_type_ object) none 31) - (set-alert-level (_type_ object) none 32) - (set-max-alert-level (_type_ object) none 33) - (set-alert-duration (_type_ object) none 34) - (get-alert-level (_type_) symbol 35) + (increase-alert-level (_type_ int target) none 30) + (decrease-alert-level (_type_ int) none 31) + (set-alert-level (_type_ int) none 32) + (set-max-alert-level (_type_ int) none 33) + (set-alert-duration (_type_ int) none 34) + (get-alert-level (_type_) int 35) (get-target (_type_) target 36) (set-object-target-level (_type_ int float) none 37) (set-object-target-count (_type_ int int) none 38) @@ -422,36 +452,36 @@ (get-object-reserve-count (_type_ int) int 40) (get-object-remaining-count (_type_ int) int 41) (activate-object (_type_ traffic-object-spawn-params) none 42) - (traffic-engine-method-43 (_type_ traffic-object-spawn-params) none 43) - (traffic-engine-method-44 (_type_ int float) none 44) - (traffic-engine-method-45 (_type_) int 45) - (new-suppression-box (_type_ object) none 46) - (traffic-engine-method-47 (_type_ traffic-suppression-params) none 47) + (activate-by-handle (_type_ traffic-object-spawn-params) none 43) + (set-parking-spot-prob (_type_ int float) none 44) + (get-random-parking-spot-type (_type_) traffic-type 45) + (new-suppression-box (_type_ traffic-suppression-params) none 46) + (remove-suppression-box (_type_ traffic-suppression-params) none 47) (update-suppression-box (_type_ traffic-suppression-params) none 48) (traffic-engine-method-49 (_type_ object int traffic-target-status) traffic-target-status 49) - (traffic-engine-method-50 (_type_ process-drawable int) process-focusable 50) - (traffic-engine-method-51 (_type_ (function none)) none 51) - (traffic-engine-method-52 (_type_) none 52) - (end-pursuit-by-type (_type_ int) none 53) + (find-closest-to-with-collide-lists (_type_ process-drawable collide-spec) process-focusable 50) + (for-all-active-processes (_type_ (function process-focusable traffic-object-type-info none)) none 51) + (send-alert-events (_type_) none 52) + (end-pursuit-by-type (_type_ traffic-type) none 53) (get-traffic-guard-type-settings (_type_ int) traffic-guard-type-settings 54) (get-guard-type-for-traffic-obj (_type_ int) uint 55) (get-traffic-guard-change-to-type (_type_ int) uint 56) (set-guard-target-count-range (_type_ int int int) none 57) - (set-object-auto-activate (_type_ object object) none 58) - (traffic-engine-method-59 (_type_ object int) none 59) + (set-object-auto-activate (_type_ int object) none 58) + (debug-check-proc-in-tracker (_type_ process int) none 59) (kill-traffic-sphere (_type_ sphere) none 60) (level-loaded (_type_ level) none 61) (level-killed (_type_ level) none 62) (traffic-engine-method-63 (_type_) none 63) (traffic-engine-method-64 (_type_) none 64) - (traffic-engine-method-65 (_type_ vis-cell) none 65) - (traffic-engine-method-66 (_type_) none 66) - (traffic-engine-method-67 (_type_) none 67) - (traffic-engine-method-68 (_type_) none 68) - (traffic-engine-method-69 (_type_) none 69) - (traffic-engine-method-70 (_type_) none 70) - (traffic-engine-method-71 (_type_) none 71) - (traffic-engine-method-72 (_type_) none 72) - (traffic-engine-method-73 (_type_) none 73) + (handle-new-vis-cell (_type_ vis-cell) none 65) + (update-sync-from-frame-counter (_type_) none 66) + (per-frame-guard-update (_type_) none 67) + (per-frame-activate-deactivate (_type_) none 68) + (per-frame-danger-update (_type_) none 69) + (update-danger-from-target (_type_) none 70) + (per-frame-alert-update (_type_) none 71) + (per-frame-suppressor-update (_type_) none 72) + (recompute-supressions (_type_) none 73) ) ) diff --git a/goal_src/jak2/levels/city/common/traffic-engine.gc b/goal_src/jak2/levels/city/common/traffic-engine.gc index 31021db39e..e2583ce7b3 100644 --- a/goal_src/jak2/levels/city/common/traffic-engine.gc +++ b/goal_src/jak2/levels/city/common/traffic-engine.gc @@ -4,6 +4,3775 @@ ;; name: traffic-engine.gc ;; name in dgo: traffic-engine ;; dgos: CWI - +(declare-type crimson-guard citizen) ;; DECOMP BEGINS +(define *traffic-suppress-activation* #f) + +(define *mysql-nav-graph* (the-as mysql-nav-graph #f)) + +(define *traffic-rigid-body-queue* (new 'static 'rigid-body-queue)) + +(defun get-level-nav-graph-by-id ((arg0 int)) + "Get the nav-graph with the given ID from any of the currently loaded levels" + (dotimes (v1-0 (-> *level* length)) + (let ((a1-3 (-> *level* level v1-0))) + (when (= (-> a1-3 status) 'active) + (when (and (!= (-> a1-3 bsp city-level-info) 0) (!= (-> a1-3 bsp city-level-info nav-graph) 0)) + (let ((a1-6 (-> a1-3 bsp city-level-info nav-graph))) + (if (and (!= a1-6 0) (= (-> a1-6 id) arg0)) + (return a1-6) + ) + ) + ) + ) + ) + ) + (the-as nav-graph #f) + ) + +(defun-debug add-debug-line-arrow () + "Does nothing!" + 0 + (none) + ) + +(defmethod debug-draw vis-cell ((obj vis-cell)) + (dotimes (s5-0 (-> obj segment-count)) + (let ((s4-0 (-> obj segment-array s5-0))) + (add-debug-line + #t + (bucket-id debug2) + (the-as vector (-> s4-0 vertex)) + (-> s4-0 vertex 1) + *color-gray* + #f + (the-as rgba -1) + ) + (add-debug-x #t (bucket-id debug2) (-> s4-0 vertex 1) *color-red*) + ) + ) + 0 + (none) + ) + +(defmethod reset-segment-counts vis-cell ((obj vis-cell)) + (set! (-> obj incoming-segment-count) 0) + (set! (-> obj segment-count) 0) + 0 + (none) + ) + +(defmethod setup-grid-from-bounding-box grid-info ((obj grid-info) (arg0 (pointer bounding-box)) (arg1 int) (arg2 int)) + "Set up a grid which fills the given bounding box" + (mem-copy! (the-as pointer (-> obj box)) arg0 32) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (dotimes (a0-2 3) + (set! (-> v1-0 data a0-2) (- (-> obj box max data a0-2) (-> obj box min data a0-2))) + ) + (let ((f0-5 (sqrtf (/ (the float arg1) (* (-> v1-0 x) (-> v1-0 z) (the float arg2)))))) + (let ((a0-6 (min 126 (+ arg1 -1)))) + (set! (-> obj dimension-array 0) (max 1 (min (the int (* f0-5 (-> v1-0 x))) a0-6))) + (set! (-> obj dimension-array 1) arg2) + (set! (-> obj dimension-array 2) (max 1 (min (the int (* f0-5 (-> v1-0 z))) a0-6))) + ) + (let* ((f1-11 (* f0-5 (-> v1-0 z))) + (f1-13 (- f1-11 (the float (the int f1-11)))) + (f0-6 (* f0-5 (-> v1-0 x))) + ) + (cond + ((< f1-13 (- f0-6 (the float (the int f0-6)))) + (if (>= arg1 (* (* (+ (-> obj dimension-array 0) 1) (-> obj dimension-array 1)) (-> obj dimension-array 2))) + (+! (-> obj dimension-array 0) 1) + ) + ) + (else + (if (>= arg1 (* (* (-> obj dimension-array 0) (-> obj dimension-array 1)) (+ (-> obj dimension-array 2) 1))) + (+! (-> obj dimension-array 2) 1) + ) + ) + ) + ) + ) + (dotimes (a0-24 3) + (set! (-> obj axis-scale a0-24) (/ (the float (-> obj dimension-array a0-24)) (-> v1-0 data a0-24))) + (set! (-> obj cell-size data a0-24) (/ (-> v1-0 data a0-24) (the float (-> obj dimension-array a0-24)))) + ) + ) + 0 + (none) + ) + +(defmethod lookup-cell-for-point grid-info ((obj grid-info) (arg0 vis-grid-pos) (arg1 vector)) + "Get the grid cell containing the point (or closest, if outside the grid)" + (set! (-> arg0 x) + (max + 0 + (min (the int (* (- (-> arg1 x) (-> obj box min x)) (-> obj axis-scale 0))) (+ (-> obj dimension-array 0) -1)) + ) + ) + (set! (-> arg0 y) + (max + 0 + (min (the int (* (- (-> arg1 y) (-> obj box min y)) (-> obj axis-scale 1))) (+ (-> obj dimension-array 1) -1)) + ) + ) + (set! (-> arg0 z) + (max + 0 + (min (the int (* (- (-> arg1 z) (-> obj box min z)) (-> obj axis-scale 2))) (+ (-> obj dimension-array 2) -1)) + ) + ) + 0 + (none) + ) + +(defmethod lookup-box-for-sphere grid-info ((obj grid-info) (arg0 vis-grid-box) (arg1 vector)) + "Get the box of cells containing the given sphere" + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (new 'stack-no-clear 'bounding-box))) + (let ((a0-1 (-> s5-0 min))) + (let ((v1-0 arg1)) + (let ((a1-1 (- (-> arg1 w)))) + (.mov vf6 a1-1) + ) + (.lvf vf4 (&-> v1-0 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a0-1 quad) vf5) + ) + (let ((a0-2 (-> s5-0 max))) + (let ((v1-1 arg1)) + (let ((a1-2 (-> arg1 w))) + (.mov vf6 a1-2) + ) + (.lvf vf4 (&-> v1-1 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a0-2 quad) vf5) + ) + (lookup-cell-for-point obj (-> arg0 min) (-> s5-0 min)) + (lookup-cell-for-point obj (-> arg0 max) (-> s5-0 max)) + ) + 0 + (none) + ) + ) + +(defmethod debug-draw-cell grid-info ((obj grid-info) (arg0 vis-grid-pos) (arg1 rgba)) + (let ((v1-0 (new 'stack-no-clear 'bounding-box))) + (dotimes (a3-0 3) + (set! (-> v1-0 min data a3-0) + (+ (-> obj box min data a3-0) (* (the float (-> arg0 data a3-0)) (-> obj cell-size data a3-0))) + ) + ) + (vector+! (-> v1-0 max) (-> v1-0 min) (-> obj cell-size)) + (add-debug-box #t (bucket-id debug2) (-> v1-0 min) (-> v1-0 max) arg1) + ) + 0 + (none) + ) + +(defmethod debug-draw-grid grid-info ((obj grid-info) (arg0 rgba)) + (draw-grid (the-as vector (-> obj box)) (-> obj box max) (-> obj dimension-array) arg0) + 0 + (none) + ) + +(defmethod try-creating-new-suppression-box traffic-suppression-params ((obj traffic-suppression-params)) + "Try getting new suppression box, return if it succeeded. ID is stored in the params." + (cond + ((= (-> obj id) -1) + (send-event *traffic-manager* 'new-suppression-box obj) + (!= (-> obj id) -1) + ) + (else + #t + ) + ) + ) + +(defmethod create-or-update-suppression-box traffic-suppression-params ((obj traffic-suppression-params)) + "If the params are already associated with a box, update. Otherwise, attempt to create a new one." + (cond + ((= (-> obj id) -1) + (send-event *traffic-manager* 'new-suppression-box obj) + (!= (-> obj id) -1) + ) + (else + (send-event *traffic-manager* 'update-suppression-box obj) + #t + ) + ) + ) + +(defmethod kill-suppression-box traffic-suppression-params ((obj traffic-suppression-params)) + "Kill a suppression box, and inform the traffic manager by setting duration to 0." + (when (!= (-> obj id) -1) + (let ((s5-0 (-> obj duration))) + (set! (-> obj duration) (the-as uint 0)) + (send-event *traffic-manager* 'update-suppression-box obj) + (set! (-> obj duration) s5-0) + ) + (set! (-> obj id) -1) + ) + (none) + ) + +(defmethod reset-boxes traffic-suppressor ((obj traffic-suppressor)) + "Clears some flags, mark all boxes as disabled." + (logclear! (-> obj flags) (traffic-suppression-flags tfs0 needs-update)) + (dotimes (v1-2 16) + (let ((a1-3 (-> obj array v1-2))) + (logclear! (-> a1-3 flags) (traffic-suppression-box-flags in-use tfsb1)) + ) + ) + 0 + (none) + ) + +(defmethod add-new-supression-box traffic-suppressor ((obj traffic-suppressor) (arg0 traffic-suppression-params)) + "Create a suppression box for these params. +The param object is updated with the ID of the box and can be later used with update-box-from-params." + (set! (-> arg0 id) -1) + (let ((v1-1 0)) + (b! #t cfg-4 :delay (nop!)) + (label cfg-1) + (let ((a2-2 (-> obj array v1-1))) + (b! (logtest? (-> a2-2 flags) (traffic-suppression-box-flags in-use)) cfg-3 :delay (empty-form)) + (set! (-> arg0 id) v1-1) + (set! (-> a2-2 flags) (traffic-suppression-box-flags in-use)) + ) + (update-box-from-params obj arg0) + (b! #t cfg-6 :delay (nop!)) + (label cfg-3) + (+! v1-1 1) + (label cfg-4) + (b! (< v1-1 16) cfg-1) + ) + (label cfg-6) + 0 + (none) + ) + +(defmethod remove-box-by-id traffic-suppressor ((obj traffic-suppressor) (arg0 int)) + "Remove a box that was previously added, by its ID." + (when (!= arg0 -1) + (logior! (-> obj flags) (traffic-suppression-flags needs-update)) + (let ((v1-6 (-> obj array arg0))) + (logclear! (-> v1-6 flags) (traffic-suppression-box-flags in-use)) + ) + ) + 0 + (none) + ) + +(defmethod update-box-from-params traffic-suppressor ((obj traffic-suppressor) (arg0 traffic-suppression-params)) + "Update a box that was previously added" + (let ((v1-0 (-> arg0 id))) + (when (!= v1-0 -1) + (logior! (-> obj flags) (traffic-suppression-flags needs-update)) + (let* ((s5-0 (-> obj array v1-0)) + (s4-1 (logior (-> s5-0 flags) (traffic-suppression-box-flags tfsb1))) + ) + (mem-copy! (the-as pointer (-> s5-0 bbox)) (the-as pointer (-> arg0 bbox)) 32) + (set! (-> s5-0 duration) (-> arg0 duration)) + (set! (-> s5-0 flags) s4-1) + ) + ) + ) + 0 + (none) + ) + +(defmethod debug-draw traffic-suppressor ((obj traffic-suppressor)) + (let ((s5-0 (new 'stack-no-clear 'bounding-box))) + (new 'stack-no-clear 'vector4w) + (let ((s4-0 *color-red*)) + (dotimes (s3-0 16) + (let ((v1-3 (-> obj array s3-0))) + (when (logtest? (-> v1-3 flags) (traffic-suppression-box-flags in-use)) + (set! (-> s5-0 min quad) (-> v1-3 bbox min quad)) + (set! (-> s5-0 max quad) (-> v1-3 bbox max quad)) + (set! (-> s5-0 min w) 1.0) + (set! (-> s5-0 max w) 1.0) + (add-debug-box #t (bucket-id debug-no-zbuf1) (-> s5-0 min) (-> s5-0 max) s4-0) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod for-all-active-processes traffic-tracker ((obj traffic-tracker) (arg0 (function process-focusable traffic-object-type-info none))) + "Call the given function on all active processes." + (let ((s4-0 (-> obj traffic))) + (countdown (s3-0 (-> obj active-object-count)) + (let ((a1-1 (-> s4-0 object-type-info-array (-> obj active-object-type-list s3-0))) + (a0-2 (handle->process (-> obj active-object-list s3-0))) + ) + (if (not (logtest? (-> (the-as process-focusable a0-2) focus-status) (focus-status inactive))) + (arg0 (the-as process-focusable a0-2) a1-1) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod for-all-active-processes-of-type traffic-tracker ((obj traffic-tracker) (arg0 traffic-type) (arg1 (function process-focusable traffic-object-type-info none))) + "Call the given function on all active processes matching the given type." + (let ((s3-0 (-> obj traffic))) + (countdown (s2-0 (-> obj active-object-count)) + (let ((a0-1 (-> obj active-object-type-list s2-0))) + (when (= a0-1 arg0) + (let ((a1-1 (-> s3-0 object-type-info-array a0-1)) + (a0-3 (handle->process (-> obj active-object-list s2-0))) + ) + (if (not (logtest? (-> (the-as process-focusable a0-3) focus-status) (focus-status inactive))) + (arg1 (the-as process-focusable a0-3) a1-1) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod add-active-process traffic-tracker ((obj traffic-tracker) (arg0 traffic-type) (arg1 handle)) + "Add a process as active." + (let ((v1-0 (-> obj active-object-count))) + (when (< v1-0 (the-as uint 126)) + (set! (-> obj active-object-list v1-0) arg1) + (set! (-> obj active-object-type-list v1-0) arg0) + (+! (-> obj active-object-count) 1) + (let ((v1-6 (-> obj traffic object-type-info-array arg0))) + (+! (-> v1-6 active-count) 1) + ) + ) + ) + 0 + (none) + ) + +(defmethod remove-active-process traffic-tracker ((obj traffic-tracker) (arg0 int)) + "Remove a process from the tracking list." + (let ((v0-0 (-> obj active-object-list arg0))) + (let ((v1-3 (-> obj active-object-type-list arg0)) + (a2-1 (+ (-> obj active-object-count) -1)) + ) + (when (>= a2-1 0) + (set! (-> obj active-object-list arg0) (-> obj active-object-list a2-1)) + (set! (-> obj active-object-type-list arg0) (-> obj active-object-type-list a2-1)) + (+! (-> obj active-object-count) -1) + (let ((v1-6 (-> obj traffic object-type-info-array v1-3))) + (+! (-> v1-6 active-count) -1) + ) + ) + ) + v0-0 + ) + ) + +(defmethod add-reserved-process traffic-tracker ((obj traffic-tracker) (arg0 traffic-type) (arg1 handle)) + "Add a process to the reserve list for a type. This process is allocated, but not yet activated." + (let* ((v1-2 (-> obj traffic object-type-info-array arg0)) + (a1-2 (-> v1-2 inactive-count)) + ) + (when (< a1-2 20) + (set! (-> v1-2 array a1-2) arg1) + (+! (-> v1-2 inactive-count) 1) + (+! (-> v1-2 reserve-count) 1) + (+! (-> obj inactive-object-count) 1) + ) + ) + 0 + (none) + ) + +(defmethod get-from-inactive-by-type traffic-tracker ((obj traffic-tracker) (arg0 traffic-type)) + "Get any handle from the inactive list of this type, and remove it from the list." + (let ((v1-2 (-> obj traffic object-type-info-array arg0)) + (a1-2 0) + (v0-0 (the-as handle #f)) + ) + (let ((a2-1 (+ (-> v1-2 inactive-count) -1))) + (when (>= a2-1 0) + (set! v0-0 (-> v1-2 array a1-2)) + (set! (-> v1-2 array a1-2) (-> v1-2 array a2-1)) + (+! (-> v1-2 inactive-count) -1) + (+! (-> v1-2 reserve-count) -1) + (+! (-> obj inactive-object-count) -1) + ) + ) + v0-0 + ) + ) + +(defmethod get-from-inactive-by-handle traffic-tracker ((obj traffic-tracker) (arg0 traffic-type) (arg1 handle)) + "Remove the given handle from the inactive list of the given type." + (let ((v1-2 (-> obj traffic object-type-info-array arg0)) + (v0-0 (the-as handle #f)) + ) + (let* ((a3-0 (+ (-> v1-2 inactive-count) -1)) + (a1-3 a3-0) + ) + (while (and (>= a1-3 0) (!= (-> v1-2 array a1-3) arg1)) + (+! a1-3 -1) + ) + (when (>= a1-3 0) + (set! v0-0 (-> v1-2 array a1-3)) + (set! (-> v1-2 array a1-3) (-> v1-2 array a3-0)) + (+! (-> v1-2 inactive-count) -1) + (+! (-> obj inactive-object-count) -1) + ) + ) + v0-0 + ) + ) + +(defmethod deactivate-object traffic-tracker ((obj traffic-tracker) (arg0 int) (arg1 symbol)) + "Send a traffic-off event (or traffic-off-force) to deactivate an object, specified by index in active object array. +Process is recycled and moved to reserved, if it deactivates." + (with-pp + (let* ((s3-0 (-> obj active-object-type-list arg0)) + (gp-0 'traffic-off) + (s2-0 (remove-active-process obj arg0)) + (s1-0 (handle->process s2-0)) + (v1-5 (the-as object #t)) + ) + (when s1-0 + (when (not (logtest? (-> (the-as process-focusable s1-0) focus-status) (focus-status inactive))) + (if arg1 + (set! gp-0 'traffic-off-force) + ) + (let ((a1-2 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-2 from) (process->ppointer pp)) + (set! (-> a1-2 num-params) 0) + (set! (-> a1-2 message) gp-0) + (set! v1-5 (send-event-function s1-0 a1-2)) + ) + ) + (cond + (v1-5 + (add-reserved-process obj s3-0 s2-0) + ) + (else + (add-active-process obj s3-0 s2-0) + (when *debug-segment* + (when arg1 + (format 0 "traffic-engine::deactivate-object: ~s event refused~%" gp-0) + (format 0 "obj ~s~%" s1-0) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + ) + +(defmethod set-process-to-killed traffic-tracker ((obj traffic-tracker) (arg0 process)) + "Move from active to killed. Separate from reserve." + (let ((v1-0 -1)) + (let ((a0-1 (process->ppointer arg0))) + (b! (not a0-1) cfg-4 :delay (nop!)) + (let ((a1-3 (new 'static 'handle :pid (-> a0-1 0 pid)))) + (b! #t cfg-5 :delay (nop!)) + (label cfg-4) + (set! a1-3 (new 'static 'handle)) + (label cfg-5) + (let ((a0-3 (logior a1-3 (new 'static 'handle :process a0-1))) + (a1-4 (-> obj active-object-count)) + ) + (b! #t cfg-8 :delay (nop!)) + (label cfg-6) + (+! a1-4 -1) + (b! (!= (-> obj active-object-list a1-4) a0-3) cfg-8 :delay (empty-form)) + (set! v1-0 (the-as int a1-4)) + (b! #t cfg-10 :delay (nop!)) + (label cfg-8) + (b! (nonzero? a1-4) cfg-6 :delay (nop!)) + ) + ) + ) + (label cfg-10) + (when (!= v1-0 -1) + (let ((s5-0 (-> obj active-object-type-list v1-0))) + (let ((a2-4 (remove-active-process obj v1-0))) + (add-reserved-process obj s5-0 a2-4) + ) + (let ((v1-5 (-> obj traffic object-type-info-array s5-0))) + (+! (-> v1-5 killed-count) 1) + (+! (-> v1-5 reserve-count) -1) + ) + ) + #t + ) + ) + 0 + (none) + ) + +(defmethod deactivate-all-of-type traffic-tracker ((obj traffic-tracker) (arg0 traffic-type) (arg1 symbol)) + "Deactivate all processes of given type" + (countdown (s3-0 (-> obj active-object-count)) + (if (= (-> obj active-object-type-list s3-0) arg0) + (deactivate-object obj (the-as int s3-0) arg1) + ) + ) + 0 + (none) + ) + +(defmethod deactivate-all traffic-tracker ((obj traffic-tracker) (arg0 symbol)) + "Deactivate all processes that are tracked" + (countdown (s4-0 (-> obj active-object-count)) + (deactivate-object obj (the-as int s4-0) arg0) + ) + 0 + (none) + ) + +(defmethod activate-from-params traffic-tracker ((obj traffic-tracker) (arg0 traffic-object-spawn-params)) + "Get a reserved process, and activate with the given params." + (local-vars (sv-16 handle)) + (let ((gp-0 (-> arg0 object-type))) + (set! (-> arg0 proc) #f) + (let ((v1-2 (-> obj traffic object-type-info-array gp-0))) + (when (and (> (-> v1-2 inactive-count) 0) (> (-> v1-2 reserve-count) 0)) + (set! sv-16 (get-from-inactive-by-type obj gp-0)) + (let ((s3-0 (handle->process sv-16))) + (when s3-0 + (cond + ((send-event s3-0 'traffic-activate arg0 (-> obj traffic)) + (set! (-> arg0 proc) s3-0) + (add-active-process obj gp-0 sv-16) + 0 + ) + (else + (add-reserved-process obj gp-0 sv-16) + ) + ) + ) + ) + 0 + ) + ) + ) + 0 + (none) + ) + +(defmethod activate-by-type traffic-tracker ((obj traffic-tracker) (arg0 traffic-type) (arg1 nav-segment) (arg2 float)) + "If possible, activate a process of the given type." + (let ((v1-2 (-> obj traffic object-type-info-array arg0))) + (when (and (> (-> v1-2 inactive-count) 0) + (> (-> v1-2 reserve-count) 0) + (< (-> v1-2 active-count) (-> v1-2 target-count)) + (logtest? (-> v1-2 flags) 4) + (logtest? (-> v1-2 flags) 8) + (or (not (logtest? (-> v1-2 flags) 1)) + (zero? (logand (-> obj traffic alert-state flags) (traffic-alert-flag alert-ending))) + ) + ) + (let ((s4-0 (new 'stack-no-clear 'mystery-traffic-object-spawn-params))) + (let ((s2-0 (-> arg1 branch))) + (set! (-> s4-0 params object-type) arg0) + (set! (-> s4-0 params guard-type) (-> v1-2 guard-type)) + (set! (-> s4-0 params nav-branch) s2-0) + (let ((v1-4 s2-0)) + (set! (-> s4-0 vector 2 x) (* 1024.0 (the float (-> v1-4 speed-limit)))) + ) + (vector-! (the-as vector (-> s4-0 vector)) (-> arg1 vertex 1) (the-as vector (-> arg1 vertex))) + (vector-normalize! (the-as vector (-> s4-0 vector)) 1.0) + (vector+float*! + (-> s4-0 params position) + (the-as vector (-> arg1 vertex)) + (the-as vector (-> s4-0 vector)) + arg2 + ) + (let ((f0-6 (* (+ -0.5 (rand-vu)) (* 256.0 (the float (-> s2-0 width)))))) + (+! (-> s4-0 params position x) (* -1.0 (-> s4-0 vector 0 z) f0-6)) + (+! (-> s4-0 params position z) (* (-> s4-0 vector 0 x) f0-6)) + ) + ) + (set! (-> s4-0 vector 2 y) + (+ (* 0.5 (-> s4-0 vector 2 x)) (* (-> obj rand) (-> obj traffic inv-density-factor) (-> arg1 spawn-spacing))) + ) + (vector-float*! (-> s4-0 params velocity) (the-as vector (-> s4-0 vector)) (-> s4-0 vector 2 x)) + (vector-float*! (-> s4-0 vector 1) (the-as vector (-> s4-0 vector)) (-> s4-0 vector 2 y)) + (when (not (sphere-hash-method-32 (-> obj object-hash) (-> s4-0 params position) (-> s4-0 vector 1) 20480.0 -1)) + (set! (-> s4-0 params behavior) (the-as uint 2)) + (set! (-> s4-0 params nav-mesh) #f) + (-> arg1 nav-mesh-id) + (if (= (-> arg1 tracker-id) 1) + (set! (-> s4-0 params nav-mesh) (get-nav-mesh (the-as actor-id (-> arg1 nav-mesh-id)))) + ) + (forward-up-nopitch->quaternion + (-> s4-0 params rotation) + (the-as vector (-> s4-0 vector)) + (new 'static 'vector :y 1.0 :w 1.0) + ) + (set! (-> obj rand) (rand-vu)) + (activate-from-params obj (-> s4-0 params)) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod activate-by-handle traffic-tracker ((obj traffic-tracker) (arg0 traffic-object-spawn-params)) + "Activate, using the handle in the params." + (local-vars (sv-16 handle)) + (let ((gp-0 (-> arg0 object-type))) + (set! (-> arg0 proc) #f) + (when (> (-> obj traffic object-type-info-array gp-0 inactive-count) 0) + (set! sv-16 (get-from-inactive-by-handle obj gp-0 (the-as handle (-> arg0 handle)))) + (let ((s3-0 (handle->process sv-16))) + (when s3-0 + (cond + ((send-event s3-0 'traffic-activate arg0 (-> obj traffic)) + (set! (-> arg0 proc) s3-0) + (add-active-process obj gp-0 sv-16) + 0 + ) + (else + (add-reserved-process obj gp-0 sv-16) + ) + ) + ) + ) + 0 + ) + ) + 0 + (none) + ) + +(defmethod reset traffic-level-data ((obj traffic-level-data)) + (set! (-> obj city-info) (the-as city-level-info 0)) + (set! (-> obj active-cell-count) (the-as uint 0)) + (set! (-> obj newly-active-cell-count) (the-as uint 0)) + 0 + (none) + ) + +(defmethod reset traffic-tracker ((obj traffic-tracker) (arg0 uint) (arg1 traffic-engine)) + (set! (-> obj traffic) arg1) + (set! (-> obj object-hash) (-> arg1 object-hash)) + (set! (-> obj rand) 0.5) + (set! (-> obj id) arg0) + (set! (-> obj active-object-count) (the-as uint 0)) + (set! (-> obj inactive-object-count) 0) + 0 + (none) + ) + +(defmethod reset traffic-alert-state ((obj traffic-alert-state)) + (set! (-> obj flags) (traffic-alert-flag)) + (set! (-> obj level) (the-as uint 0)) + (set! (-> obj duration) (the-as uint 9000)) + (set! (-> obj alarm-sound-id) (new-sound-id)) + (set! (-> obj guard-inaccuracy-factor) 1.0) + (dotimes (v1-2 3) + (let ((a0-4 (-> obj target-status-array v1-2))) + (set! (-> a0-4 flags) (traffic-target-flag)) + (set! (-> a0-4 handle) (the-as handle #f)) + ) + ) + (set! (-> obj guard-type-info-array 0 object-type) (traffic-type crimson-guard-1)) + (set! (-> obj guard-type-info-array 1 object-type) (traffic-type crimson-guard-1)) + (set! (-> obj guard-type-info-array 2 object-type) (traffic-type crimson-guard-1)) + (set! (-> obj guard-type-info-array 3 object-type) (traffic-type crimson-guard-2)) + (set! (-> obj guard-type-info-array 4 object-type) (traffic-type guard-bike)) + (set! (-> obj guard-type-info-array 5 object-type) (traffic-type hellcat)) + (dotimes (v1-11 21) + (set! (-> obj guard-type-mask-from-object-type v1-11) (the-as uint 0)) + ) + (dotimes (v1-14 6) + (let ((a0-10 (-> obj guard-type-info-array v1-14 object-type))) + (set! (-> obj guard-type-mask-from-object-type a0-10) + (the-as uint (logior (ash 1 v1-14) (-> obj guard-type-mask-from-object-type a0-10))) + ) + ) + ) + 0 + (none) + ) + +(defmethod reset-and-init-from-manager traffic-engine ((obj traffic-engine) (arg0 process)) + "Reset the traffic engine" + (set! (-> obj manager) (process->handle arg0)) + (set! (-> obj flags) (the-as uint 0)) + (set! (-> obj danger-sphere-count) 0) + (set! (-> *game-info* wanted-flash) #f) + (let ((v1-4 (-> obj inactive-object-array))) + (dotimes (a0-5 21) + (let ((a1-3 (-> obj object-type-info-array a0-5))) + (set! (-> a1-3 flags) (the-as uint 6)) + (set! (-> a1-3 inactive-count) 0) + (set! (-> a1-3 active-count) 0) + (set! (-> a1-3 target-count) 20) + (set! (-> a1-3 reserve-count) (the-as uint #x7d00)) + (set! (-> a1-3 killed-count) (the-as uint 0)) + (set! (-> a1-3 array) v1-4) + (set! (-> a1-3 level) #f) + ) + (set! v1-4 (&-> v1-4 20)) + ) + ) + (set! (-> obj object-type-info-array 6 guard-type) (the-as uint 0)) + (set! (-> obj object-type-info-array 20 level) (the-as level 'ctywide)) + (let ((v1-8 11)) + (dotimes (a0-6 10) + (set! (-> obj object-type-info-array v1-8 tracker-index) (the-as uint 0)) + (+! v1-8 1) + ) + ) + (let ((v1-11 0)) + (dotimes (a0-7 11) + (set! (-> obj object-type-info-array v1-11 tracker-index) (the-as uint 1)) + (+! v1-11 1) + ) + ) + (dotimes (s5-0 2) + (reset (-> obj tracker-array s5-0) (the-as uint s5-0) obj) + ) + (reset-boxes (-> obj suppressor)) + (set! (-> obj object-hash object-count) 0) + (let* ((v1-24 (-> obj object-hash)) + (a0-15 + (/ (+ (* (* (* (-> v1-24 dimension-array 0) (-> v1-24 dimension-array 1)) (-> v1-24 dimension-array 2)) + (-> v1-24 bucket-size) + ) + 15 + ) + 16 + ) + ) + (v1-25 (the-as (pointer uinteger) (-> v1-24 bucket-array))) + ) + (while (nonzero? a0-15) + (+! a0-15 -1) + (set! (-> (the-as (pointer uint128) v1-25) 0) (the-as uint128 0)) + (set! v1-25 (&-> (the-as (pointer grid-hash-word) v1-25) 16)) + ) + ) + 0 + (dotimes (s5-1 2) + (reset (-> obj level-data-array s5-1)) + ) + (dotimes (s5-2 (-> *level* length)) + (let ((a1-12 (-> *level* level s5-2))) + (if (= (-> a1-12 status) 'active) + (level-loaded obj a1-12) + ) + ) + ) + (reset (-> obj alert-state)) + 0 + (none) + ) + +(defmethod stop-alarm-sound traffic-engine ((obj traffic-engine)) + (sound-stop (-> obj alert-state alarm-sound-id)) + 0 + (none) + ) + +(defmethod level-loaded traffic-engine ((obj traffic-engine) (arg0 level)) + "Call after loading a level to patch the data in the bsp" + (format #t "traffic-engine: level birth ~S~%" (-> arg0 nickname)) + (cond + ((or (not *debug-segment*) + (not (and (get-nav-graph-editor) (= (-> (get-nav-graph-editor) nav-graph nav_graph_id) 1))) + ) + (when (and (nonzero? (-> arg0 bsp city-level-info)) (nonzero? (-> arg0 bsp city-level-info nav-graph))) + (let ((s4-0 (-> arg0 bsp city-level-info))) + (let ((v1-13 (-> arg0 bsp city-level-info nav-graph))) + (when (not (-> v1-13 patched)) + (dotimes (a0-8 (the-as int (-> s4-0 cell-count))) + (let ((a1-3 (-> s4-0 cell-array a0-8))) + (set! (-> a1-3 segment-array) + (the-as (inline-array nav-segment) (-> s4-0 segment-array (the-as int (the-as uint (-> a1-3 segment-array))))) + ) + ) + ) + (dotimes (a0-11 (-> s4-0 segment-count)) + (let ((a1-6 (-> s4-0 segment-array a0-11))) + (set! (-> a1-6 branch) (-> v1-13 branch-array (the-as uint (-> a1-6 branch)))) + ) + ) + (dotimes (a0-14 (-> v1-13 node-count)) + (let ((a1-9 (-> v1-13 node-array a0-14))) + (set! (-> a1-9 branch-array) + (the-as (inline-array nav-branch) (-> v1-13 branch-array (the-as uint (-> a1-9 branch-array)))) + ) + ) + ) + (dotimes (a0-17 (-> v1-13 branch-count)) + (let* ((a1-12 (-> v1-13 branch-array a0-17)) + (t0-1 (the-as object (-> a1-12 src-node))) + (a2-12 (the-as object (-> a1-12 dest-node))) + ) + (set! (-> a1-12 src-node) (-> v1-13 node-array (the-as uint t0-1))) + (cond + ((< #x186a0 (the-as int a2-12)) + (let ((a2-13 (- (the-as uint #xffffffff) (the-as uint a2-12)))) + (set! (-> a1-12 dest-node) (-> v1-13 link-array a2-13 dummy-node)) + ) + ) + (else + (set! (-> a1-12 dest-node) (-> v1-13 node-array (the-as uint a2-12))) + ) + ) + ) + ) + (set! (-> v1-13 patched) #t) + ) + (dotimes (a0-21 (-> v1-13 branch-count)) + (set! (-> v1-13 branch-array a0-21 user-count) (the-as uint 0)) + 0 + ) + ) + (dotimes (v1-16 (the-as int (-> s4-0 cell-count))) + (let ((a0-23 (-> s4-0 cell-array v1-16))) + (set! (-> a0-23 flags) (vis-cell-flag)) + (set! (-> a0-23 prev-flags) (vis-cell-flag)) + ) + 0 + ) + (let ((s3-0 0)) + (dotimes (s2-0 (-> s4-0 segment-count)) + (let ((s1-0 (-> s4-0 segment-array s2-0))) + (vector-vector-distance (the-as vector (-> s1-0 vertex)) (-> s1-0 vertex 1)) + (when (< (-> s1-0 spawn-spacing) 0.0) + (inspect s1-0) + #t + (+! s3-0 1) + (set! (-> s1-0 spawn-spacing) (fabs (-> s1-0 spawn-spacing))) + ) + ) + ) + (format #t "birth-level ~s found ~d bad segs~%" arg0 s3-0) + ) + ) + ) + ) + (else + 0 + ) + ) + (let ((s4-1 (the-as traffic-level-data #f))) + (dotimes (v1-31 2) + (let ((a0-34 (-> obj level-data-array v1-31))) + (if (zero? (-> a0-34 city-info)) + (set! s4-1 a0-34) + ) + ) + ) + (if (not s4-1) + (format 0 "level-data not found~%") + ) + (when s4-1 + (set! (-> s4-1 city-info) (-> arg0 bsp city-level-info)) + (set! (-> s4-1 active-cell-count) (the-as uint 0)) + 0 + ) + ) + (dotimes (gp-1 (-> *level* length)) + (let ((v1-43 (-> *level* level gp-1))) + (when (= (-> v1-43 status) 'active) + (when (nonzero? (-> v1-43 bsp city-level-info)) + (let ((s5-1 (-> v1-43 bsp city-level-info nav-graph))) + (when (and (nonzero? s5-1) (-> s5-1 patched)) + (dotimes (s4-2 (-> s5-1 link-count)) + (let ((s3-1 (-> s5-1 link-array s4-2))) + (when (not (-> s3-1 dest-graph)) + (let ((s2-1 (get-level-nav-graph-by-id (the-as int (-> s3-1 dest-graph-id))))) + (when (and s2-1 (-> s2-1 patched)) + (dotimes (s1-1 (-> s2-1 node-count)) + (when (= (-> s3-1 dest-node-id) (-> s2-1 node-array s1-1 id)) + (set! (-> s3-1 dest-graph) s2-1) + (set-dst-node (-> s5-1 branch-array (-> s3-1 src-branch-id)) (-> s2-1 node-array s1-1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod level-killed traffic-engine ((obj traffic-engine) (arg0 level)) + "Call after removing a level. Kills processes and unlinks nav" + (let ((s4-0 (-> arg0 bsp city-level-info nav-graph))) + (dotimes (v1-2 2) + (let ((a0-4 (-> obj level-data-array v1-2))) + (when (= (-> a0-4 city-info) (-> arg0 bsp city-level-info)) + (set! (-> a0-4 city-info) (the-as city-level-info 0)) + 0 + ) + ) + ) + (when (nonzero? s4-0) + (dotimes (s3-0 (-> *level* length)) + (let ((v1-9 (-> *level* level s3-0))) + (when (= (-> v1-9 status) 'active) + (when (and (!= arg0 v1-9) (!= (-> v1-9 bsp city-level-info) 0)) + (let ((s2-0 (-> v1-9 bsp city-level-info nav-graph))) + (when (nonzero? s2-0) + (dotimes (s1-0 (-> s2-0 link-count)) + (let ((s0-0 (-> s2-0 link-array s1-0))) + (when (= (-> s0-0 dest-graph) s4-0) + (set! (-> s0-0 dest-graph) (get-level-nav-graph-by-id (the-as int (-> s0-0 dest-graph-id)))) + (when (-> s0-0 dest-graph) + (set-dst-node (-> s2-0 branch-array (-> s0-0 src-branch-id)) (-> s0-0 dummy-node)) + (set! (-> s0-0 dest-graph) #f) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let ((s4-1 (-> arg0 bsp city-level-info nav-graph))) + (dotimes (s3-1 (-> s4-1 link-count)) + (let ((s2-1 (-> s4-1 link-array s3-1))) + (set-dst-node (-> s4-1 branch-array (-> s2-1 src-branch-id)) (-> s2-1 dummy-node)) + (set! (-> s2-1 dest-graph) #f) + ) + ) + ) + (deactivate-all-from-level obj (-> arg0 name)) + 0 + (none) + ) + +(defmethod for-all-active-processes traffic-engine ((obj traffic-engine) (arg0 (function process-focusable traffic-object-type-info none))) + (dotimes (s4-0 2) + (for-all-active-processes (-> obj tracker-array s4-0) arg0) + ) + 0 + (none) + ) + +(defmethod add-object traffic-engine ((obj traffic-engine) (arg0 traffic-type) (arg1 process)) + (add-reserved-process + (-> obj tracker-array (-> obj object-type-info-array arg0 tracker-index)) + arg0 + (process->handle arg1) + ) + 0 + (none) + ) + +(defmethod child-killed traffic-engine ((obj traffic-engine) (arg0 process)) + "handle killing a child process" + (cond + ((type? arg0 citizen) + (set-process-to-killed (-> obj vehicle-tracker-array) arg0) + ) + ((type? arg0 vehicle) + (set-process-to-killed (-> obj citizen-tracker-array) arg0) + ) + (else + 0 + ) + ) + 0 + (none) + ) + +(defmethod activate-one-citizen traffic-engine ((obj traffic-engine) (arg0 nav-segment) (arg1 float)) + (let ((a1-1 (+ (rand-vu-int-count 10) 11))) + (activate-by-type (-> obj citizen-tracker-array) (the-as traffic-type a1-1) arg0 arg1) + ) + 0 + (none) + ) + +(defmethod activate-one-vehicle traffic-engine ((obj traffic-engine) (arg0 nav-segment) (arg1 float)) + (let ((a1-1 0)) + (dotimes (v1-0 11) + (if (zero? (-> obj object-type-info-array v1-0 inactive-count)) + (set! a1-1 (logior a1-1 (ash 1 v1-0))) + ) + ) + (let ((a1-2 (rand-vu-int-count-excluding 11 a1-1))) + (activate-by-type (-> obj vehicle-tracker-array) (the-as traffic-type a1-2) arg0 arg1) + ) + ) + 0 + (none) + ) + +(defmethod handle-new-vis-cell traffic-engine ((obj traffic-engine) (arg0 vis-cell)) + (dotimes (s4-0 (-> arg0 segment-count)) + (let* ((s3-0 (-> arg0 segment-array s4-0)) + (s1-0 (-> s3-0 tracker-id)) + ) + (when (and (logtest? (logxor (-> arg0 flags) (the-as uint (-> arg0 prev-flags))) (ash 1 s1-0)) + (and (not (logtest? (-> arg0 flags) (vis-cell-flag suppress))) + (not (or (can-dest-be-used? obj (-> s3-0 branch)) (let ((a0-7 (-> s3-0 branch))) + (>= (-> a0-7 user-count) (-> a0-7 max-user-count)) + ) + ) + ) + ) + ) + (let* ((s2-0 (-> obj tracker-array s1-0)) + (f30-0 (* (-> s2-0 rand) (-> obj inv-density-factor) (-> s3-0 spawn-spacing))) + ) + (cond + ((= s1-0 1) + (when (nonzero? (-> s3-0 nav-mesh-id)) + (while (and (< f30-0 (-> s3-0 length)) (> (-> s2-0 inactive-object-count) 0)) + (activate-one-vehicle obj s3-0 f30-0) + (set! f30-0 (+ 24576.0 (* (-> s2-0 rand) (-> obj inv-density-factor) (-> s3-0 spawn-spacing)) f30-0)) + ) + ) + ) + (else + (while (and (< f30-0 (-> s3-0 length)) (> (-> s2-0 inactive-object-count) 0)) + (activate-one-citizen obj s3-0 f30-0) + (set! f30-0 (+ 49152.0 (* (-> s2-0 rand) (-> obj inv-density-factor) (-> s3-0 spawn-spacing)) f30-0)) + ) + ) + ) + (if (>= f30-0 (-> s3-0 length)) + (set! (-> s2-0 rand) + (fmax 0.0 (- (-> s2-0 rand) (/ (-> s3-0 length) (* (-> s3-0 spawn-spacing) (-> obj inv-density-factor))))) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod debug-draw traffic-level-data ((obj traffic-level-data)) + (local-vars (sv-16 nav-node) (sv-20 nav-branch) (sv-80 nav-node) (sv-84 vector) (sv-88 vector) (sv-92 vector)) + (when (and (nonzero? (-> obj city-info)) (nonzero? (-> obj city-info nav-graph))) + (let ((s5-0 (-> obj city-info nav-graph))) + (let ((v1-6 (-> s5-0 node-array 0))) + (countdown (a0-3 (-> s5-0 node-count)) + (logclear! (-> v1-6 flags) (nav-node-flag-byte visited)) + (&+! v1-6 32) + ) + ) + (dotimes (s4-0 (the-as int (-> obj active-cell-count))) + (let ((a0-4 (-> obj active-cell-list s4-0))) + (dotimes (v1-11 (-> a0-4 segment-count)) + (let ((a1-5 (-> a0-4 segment-array v1-11 branch src-node))) + (logior! (-> a1-5 flags) (nav-node-flag-byte visited)) + ) + ) + (debug-draw a0-4) + ) + ) + (set! sv-16 (-> s5-0 node-array 0)) + (countdown (gp-1 (-> s5-0 node-count)) + (when (logtest? (-> sv-16 flags) (nav-node-flag-byte visited)) + (debug-draw sv-16) + (dotimes (s5-1 (-> sv-16 branch-count)) + (set! sv-20 (-> sv-16 branch-array s5-1)) + (set! sv-80 (-> sv-20 dest-node)) + (set! sv-84 (new 'stack-no-clear 'vector)) + (set! sv-88 (new 'stack-no-clear 'vector)) + (set! sv-92 (new 'stack-no-clear 'vector)) + (let ((a1-7 sv-16) + (v1-35 sv-88) + ) + (set! (-> v1-35 quad) (-> a1-7 position quad)) + (set! (-> v1-35 w) 1.0) + ) + (let ((a1-10 sv-80) + (v1-36 sv-92) + ) + (set! (-> v1-36 quad) (-> a1-10 position quad)) + (set! (-> v1-36 w) 1.0) + ) + (vector-! sv-84 sv-92 sv-88) + (add-debug-vector #t (bucket-id debug2) sv-88 sv-84 (meters 0.00023193359) *color-light-green*) + (vector+float*! sv-84 sv-88 sv-84 0.5) + (let ((s4-1 add-debug-text-3d) + (s3-0 #t) + (s2-0 324) + ) + (format (clear *temp-string*) "~D" (-> sv-20 user-count)) + (s4-1 + s3-0 + (the-as bucket-id s2-0) + *temp-string* + sv-84 + (if (< (-> sv-20 user-count) (-> sv-20 max-user-count)) + (font-color yellow-#f3f300) + (font-color precursor-#ec3b00) + ) + (the-as vector2h #f) + ) + ) + ) + ) + (set! sv-16 (&+ sv-16 32)) + ) + ) + ) + 0 + (none) + ) + +(defmethod debug-unused traffic-engine ((obj traffic-engine)) + (dotimes (v1-0 (-> *level* length)) + (let ((a0-4 (-> *level* level v1-0))) + (when (= (-> a0-4 status) 'active) + (when (and (!= (-> a0-4 bsp city-level-info) 0) (!= (-> a0-4 bsp city-level-info nav-graph) 0)) + ) + ) + ) + ) + (when #f + ) + 0 + (none) + ) + +(defmethod sphere-in-loaded-city-infos? traffic-engine ((obj traffic-engine) (arg0 int) (arg1 vector)) + (dotimes (s3-0 2) + (let ((v1-3 (-> obj level-data-array s3-0))) + (when (nonzero? (-> v1-3 city-info)) + (if (sphere-in-grid? (-> v1-3 city-info) arg0 (the-as int arg1)) + (return #t) + ) + ) + ) + ) + #f + ) + +(defmethod can-dest-be-used? traffic-engine ((obj traffic-engine) (arg0 nav-branch)) + (let ((v1-0 (-> arg0 src-node))) + (or (logtest? (-> arg0 flags) 1) + (logtest? (-> v1-0 flags) (nav-node-flag-byte blocked)) + (not (-> arg0 dest-node)) + (>= (-> arg0 user-count) (-> arg0 max-user-count)) + ) + ) + ) + +(defmethod update-sync-from-frame-counter traffic-engine ((obj traffic-engine)) + (with-pp + (+! (-> obj sync-clock) 1) + (set! (-> obj sync-mask-8) (the-as uint (ash 1 (logand (-> obj sync-clock) 7)))) + (set! (-> obj sync-mask-16) (the-as uint (ash 1 (logand (-> obj sync-clock) 15)))) + (set! (-> obj sync-mask-32) (the-as uint (ash 1 (logand (-> obj sync-clock) 31)))) + (let ((v1-10 (/ (-> pp clock frame-counter) 300))) + (set! (-> obj sync-array 0) (the-as uint 255)) + (let ((a1-12 (mod v1-10 20))) + (set! (-> obj sync-array 1) (the-as uint (cond + ((>= 6 a1-12) + 1 + ) + ((>= 9 a1-12) + 2 + ) + ((>= 16 a1-12) + 4 + ) + (else + 8 + ) + ) + ) + ) + ) + (let ((a1-15 (mod v1-10 30))) + (set! (-> obj sync-array 2) (the-as uint (cond + ((>= 6 a1-15) + 1 + ) + ((>= 9 a1-15) + 2 + ) + ((>= 16 a1-15) + 4 + ) + ((>= 19 a1-15) + 8 + ) + ((>= 26 a1-15) + 16 + ) + (else + 32 + ) + ) + ) + ) + ) + (let ((v1-11 (mod v1-10 40))) + (set! (-> obj sync-array 3) (the-as uint (cond + ((>= 6 v1-11) + 1 + ) + ((>= 9 v1-11) + 2 + ) + ((>= 16 v1-11) + 4 + ) + ((>= 19 v1-11) + 8 + ) + ((>= 26 v1-11) + 16 + ) + ((>= 29 v1-11) + 32 + ) + ((>= 36 v1-11) + 64 + ) + (else + 128 + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + ) + +(defmethod update-danger-from-target traffic-engine ((obj traffic-engine)) + "make people run away from jak when he is dangerous." + (local-vars (v1-20 float) (v1-32 float)) + (with-pp + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 *target*)) + (when s5-0 + (let ((v1-1 (-> obj danger-sphere-array))) + (set! (-> v1-1 0 handle) (the-as uint (process->handle s5-0))) + (let ((a0-4 (-> s5-0 focus-status)) + (f0-0 0.0) + (f1-0 0.0) + (f3-0 1.0) + (f2-0 0.0) + ) + (cond + ((logtest? (focus-status mech dark shooting) a0-4) + (set! f0-0 245760.0) + (set! f1-0 163840.0) + (set! f2-0 1.0) + (set! f3-0 0.0) + ) + ((logtest? (focus-status gun) a0-4) + (set! f0-0 102400.0) + (set! f1-0 61440.0) + (set! f2-0 0.5) + (set! f3-0 0.5) + ) + ((logtest? (focus-status board pilot) a0-4) + (set! f0-0 40960.0) + (set! f1-0 24576.0) + (set! f2-0 0.5) + ) + ((logtest? a0-4 (focus-status dangerous)) + (set! f0-0 61440.0) + (set! f1-0 40960.0) + (set! f3-0 0.0) + (set! f2-0 0.5) + ) + (else + (set! f3-0 1.5) + ) + ) + (set! (-> v1-1 0 decay-rate) (* 0.1 f3-0)) + (when (< (-> v1-1 0 danger-level) f2-0) + (set! (-> v1-1 0 danger-level) f2-0) + (set! (-> v1-1 0 sphere r) f1-0) + (set! (-> v1-1 0 notify-radius) f0-0) + ) + ) + (let ((f0-1 (-> v1-1 0 sphere r))) + (set! (-> v1-1 0 sphere quad) (-> s5-0 control trans quad)) + (set! (-> v1-1 0 sphere r) f0-1) + ) + (set! (-> v1-1 0 velocity quad) (-> s5-0 control transv quad)) + (let ((f0-3 (- (-> v1-1 0 danger-level) (* (-> v1-1 0 decay-rate) (-> pp clock seconds-per-frame))))) + (set! (-> v1-1 0 danger-level) (fmax 0.0 f0-3)) + ) + ) + (let ((s3-0 (-> s5-0 focus-status)) + (f30-0 0.0) + (s4-0 (new 'stack-no-clear 'inline-array 'traffic-suppression-box 2)) + ) + (set! (-> s4-0 0 bbox max quad) (-> s5-0 control transv quad)) + (vector-z-quaternion! (the-as vector (-> s4-0 1)) (get-quat s5-0 3)) + (set! (-> s4-0 1 data 16) (the-as uint 3)) + (cond + ((logtest? (focus-status shooting) s3-0) + (vector-float*! (the-as vector (-> s4-0 0)) (the-as vector (-> s4-0 1)) 409600.0) + (set! f30-0 4096.0) + (set! (-> s4-0 1 data 16) (the-as uint 0)) + 0 + ) + ((and (logtest? (focus-status gun) s3-0) + (not (and (logtest? (focus-status pilot) s3-0) (let* ((v1-19 (-> s4-0 0 bbox max)) + (f0-6 40960.0) + (f0-8 (* f0-6 f0-6)) + ) + (.lvf vf1 (&-> v1-19 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-20 vf1) + (< f0-8 v1-20) + ) + ) + ) + ) + (vector-float*! (the-as vector (-> s4-0 0)) (the-as vector (-> s4-0 1)) 163840.0) + (set! f30-0 8192.0) + (set! (-> s4-0 1 data 16) (the-as uint 1)) + ) + ((logtest? (focus-status dangerous board pilot) s3-0) + (vector-float*! (the-as vector (-> s4-0 0)) (-> s4-0 0 bbox max) 2.0) + (let* ((v1-31 (-> s4-0 0)) + (f0-11 20480.0) + (f0-13 (* f0-11 f0-11)) + ) + (.lvf vf1 (&-> v1-31 bbox min 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-32 vf1) + (if (< f0-13 v1-32) + (set! f30-0 20480.0) + ) + ) + (set! (-> s4-0 1 data 16) (the-as uint (cond + ((logtest? (focus-status pilot) s3-0) + 3 + ) + ((logtest? (focus-status board) s3-0) + 2 + ) + ((logtest? s3-0 (focus-status dangerous)) + 4 + ) + (else + 5 + ) + ) + ) + ) + ) + ) + (when (< 0.0 f30-0) + (let ((s3-1 (new 'stack-no-clear 'array 'collide-shape 40)) + (s2-1 (new 'stack 'traffic-danger-info)) + ) + (set! (-> s2-1 sphere quad) (-> s5-0 control trans quad)) + (set! (-> s2-1 danger-type) (the-as traffic-danger-type (-> s4-0 1 data 16))) + (set! (-> s2-1 sphere r) f30-0) + (set! (-> s2-1 velocity quad) (-> s4-0 0 bbox min quad)) + (let ((gp-1 (fill-actor-list-for-line-sphere + (-> obj object-hash) + (-> s2-1 sphere) + (-> s2-1 velocity) + (-> s2-1 sphere r) + s3-1 + 40 + -1 + ) + ) + ) + (dotimes (s5-1 gp-1) + (let* ((s4-1 (-> s3-1 s5-1)) + (a0-52 (if (type? s4-1 citizen) + s4-1 + ) + ) + ) + (if a0-52 + (send-event (the-as process-tree a0-52) 'clear-path s2-1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + ) + ) + +(defmethod per-frame-danger-update traffic-engine ((obj traffic-engine)) + "see what's dangerous and make people avoid it." + (update-danger-from-target obj) + (dotimes (s5-0 (-> obj danger-sphere-count)) + (let ((s4-0 (-> obj danger-sphere-array s5-0))) + (when (< 0.0 (-> s4-0 danger-level)) + (let ((s3-0 (new 'stack-no-clear 'array 'collide-shape 40)) + (a1-0 (new 'stack-no-clear 'sphere)) + ) + (set! (-> a1-0 quad) (-> s4-0 sphere quad)) + (set! (-> a1-0 r) (-> s4-0 notify-radius)) + (let ((s2-0 (fill-actor-list-for-sphere (-> obj object-hash) a1-0 s3-0 40))) + (dotimes (s1-0 s2-0) + (let* ((s0-0 (-> s3-0 s1-0)) + (a0-6 (if (type? s0-0 citizen) + s0-0 + ) + ) + ) + (if a0-6 + (send-event + (the-as process-tree a0-6) + (if (< 0.5 (-> s4-0 danger-level)) + 'panic + 'avoid + ) + s4-0 + ) + ) + ) + ) + ) + ) + ) + ) + ) + (set! (-> obj danger-sphere-count) 1) + 0 + (none) + ) + +(defmethod add-danger traffic-engine ((obj traffic-engine) (arg0 traffic-danger-info)) + "Add a danger sphere and suppression box." + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((a1-1 (new 'stack-no-clear 'traffic-suppression-params))) + (let ((a0-1 (-> a1-1 bbox))) + (let ((v1-0 (-> arg0 sphere))) + (let ((a2-0 (- (-> arg0 notify-radius)))) + (.mov vf6 a2-0) + ) + (.lvf vf4 (&-> v1-0 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a0-1 min quad) vf5) + ) + (let ((a0-2 (-> a1-1 bbox max))) + (let ((v1-1 (-> arg0 sphere))) + (let ((a2-1 (-> arg0 notify-radius))) + (.mov vf6 a2-1) + ) + (.lvf vf4 (&-> v1-1 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a0-2 quad) vf5) + ) + (set! (-> a1-1 duration) (the-as uint 1500)) + (new-suppression-box obj a1-1) + ) + (let ((v1-5 (-> obj danger-sphere-count))) + (when (< v1-5 4) + (let ((a0-5 (-> obj danger-sphere-array v1-5))) + (mem-copy! (the-as pointer a0-5) (the-as pointer arg0) 54) + ) + (+! (-> obj danger-sphere-count) 1) + ) + ) + 0 + (none) + ) + ) + +(defmethod kill-traffic-sphere traffic-engine ((obj traffic-engine) (arg0 sphere)) + "Kill everything in the sphere with a traffic-off-force." + (let ((gp-0 (new 'stack-no-clear 'array 'collide-shape 64))) + (countdown (s5-0 (fill-actor-list-for-sphere *actor-hash* arg0 gp-0 64)) + (let* ((s4-0 (-> gp-0 s5-0)) + (v1-3 (if (type? s4-0 collide-shape) + s4-0 + ) + ) + ) + (if v1-3 + (send-event (-> v1-3 process) 'traffic-off-force) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod per-frame-activate-deactivate traffic-engine ((obj traffic-engine)) + "per-frame activate and deactivate processes." + (local-vars (sv-48 int) (sv-64 nav-segment)) + (set! (-> obj object-hash object-count) 0) + (let* ((v1-1 (-> obj object-hash)) + (a0-6 (/ (+ (* (* (* (-> v1-1 dimension-array 0) (-> v1-1 dimension-array 1)) (-> v1-1 dimension-array 2)) + (-> v1-1 bucket-size) + ) + 15 + ) + 16 + ) + ) + (v1-2 (the-as (pointer uinteger) (-> v1-1 bucket-array))) + ) + (while (nonzero? a0-6) + (+! a0-6 -1) + (set! (-> (the-as (pointer uint128) v1-2) 0) (the-as uint128 0)) + (set! v1-2 (&-> (the-as (pointer grid-hash-word) v1-2) 16)) + ) + ) + 0 + (new 'stack-no-clear 'vector) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (let ((a2-0 *target*)) + (when a2-0 + (cond + ((logtest? (focus-status pilot) (-> a2-0 focus-status)) + (when (nonzero? (-> a2-0 pilot)) + (let ((a2-1 (handle->process (-> a2-0 pilot vehicle)))) + (when a2-1 + (set! (-> s5-0 quad) (-> (the-as process-focusable a2-1) root-override root-prim prim-core world-sphere quad)) + (spatial-hash-method-39 (-> obj object-hash) s5-0 (the-as hash-object-info a2-1)) + ) + ) + ) + ) + (else + (set! (-> s5-0 quad) (-> a2-0 control trans quad)) + (set! (-> s5-0 w) 20480.0) + (spatial-hash-method-39 (-> obj object-hash) s5-0 (the-as hash-object-info a2-0)) + ) + ) + ) + ) + (countdown (s4-0 (-> obj citizen-tracker-array active-object-count)) + (let ((s3-0 (handle->process (-> obj citizen-tracker-array active-object-list s4-0)))) + (cond + (s3-0 + (cond + ((logtest? (-> (the-as vehicle s3-0) focus-status) (focus-status inactive)) + (deactivate-object (-> obj citizen-tracker-array) (the-as int s4-0) #f) + ) + ((begin + (let ((v1-33 (-> (the-as vehicle s3-0) root-override-2))) + (set! (-> s5-0 quad) (-> v1-33 trans quad)) + (set! (-> s5-0 w) (-> v1-33 root-prim prim-core world-sphere w)) + ) + (sphere-in-loaded-city-infos? obj (the-as int s5-0) (the-as vector 0)) + ) + (set! (-> (the-as vehicle s3-0) traffic-hash-id) + (spatial-hash-method-39 (-> obj object-hash) s5-0 (the-as hash-object-info s3-0)) + ) + ) + (else + (deactivate-object (-> obj citizen-tracker-array) (the-as int s4-0) #f) + ) + ) + ) + (else + (remove-active-process (-> obj citizen-tracker-array) (the-as int s4-0)) + ) + ) + ) + ) + (countdown (s4-1 (-> obj vehicle-tracker-array active-object-count)) + (let ((s3-1 (handle->process (-> obj vehicle-tracker-array active-object-list s4-1)))) + (cond + (s3-1 + (cond + ((logtest? (-> (the-as process-focusable s3-1) focus-status) (focus-status inactive)) + (deactivate-object (-> obj vehicle-tracker-array) (the-as int s4-1) #f) + ) + ((begin + (let ((v1-54 (-> (the-as process-focusable s3-1) root-override))) + (set! (-> s5-0 quad) (-> v1-54 trans quad)) + (set! (-> s5-0 w) (-> v1-54 root-prim prim-core world-sphere w)) + ) + (sphere-in-loaded-city-infos? obj (the-as int s5-0) (the-as vector 1)) + ) + (spatial-hash-method-39 (-> obj object-hash) s5-0 (the-as hash-object-info s3-1)) + ) + (else + (deactivate-object (-> obj vehicle-tracker-array) (the-as int s4-1) #f) + ) + ) + ) + (else + (remove-active-process (-> obj vehicle-tracker-array) (the-as int s4-1)) + ) + ) + ) + ) + ) + (dotimes (s5-1 2) + (let ((s4-2 (-> obj level-data-array s5-1))) + (when (nonzero? (-> s4-2 city-info)) + (dotimes (s3-2 (the-as int (-> s4-2 newly-active-cell-count))) + (let ((a1-22 (-> s4-2 newly-active-cell-list s3-2))) + (handle-new-vis-cell obj a1-22) + ) + ) + (dotimes (s3-3 2) + (when (> (-> obj tracker-array s3-3 inactive-object-count) 0) + (let ((s2-0 (the-as nav-segment #f))) + (let ((f30-0 10000000000000000000000000000000000000.0)) + (dotimes (s1-0 (the-as int (-> s4-2 active-cell-count))) + (let ((s0-0 (-> s4-2 active-cell-list s1-0))) + (when (and (logtest? (-> s0-0 flags) (ash 1 s3-3)) (zero? (logand (-> s0-0 flags) (vis-cell-flag suppress)))) + (set! sv-48 0) + (while (< sv-48 (-> s0-0 incoming-segment-count)) + (set! sv-64 (-> s0-0 segment-array sv-48)) + (when (= (-> sv-64 tracker-id) s3-3) + (when (not (logtest? (-> s4-2 city-info cell-array (-> sv-64 from-cell-id) flags) (ash 1 s3-3))) + (let ((f0-3 (rand-vu))) + (when (< f0-3 f30-0) + (set! f30-0 f0-3) + (set! s2-0 sv-64) + ) + ) + ) + ) + (set! sv-48 (+ sv-48 1)) + ) + ) + ) + ) + ) + (when s2-0 + (let ((a0-51 (-> s2-0 branch))) + (when (not (or (>= (-> a0-51 user-count) (-> a0-51 max-user-count)) (can-dest-be-used? obj (-> s2-0 branch)))) + (cond + ((= s3-3 1) + (if (nonzero? (-> s2-0 nav-mesh-id)) + (activate-one-vehicle obj s2-0 0.0) + ) + ) + (else + (activate-one-citizen obj s2-0 0.0) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod update-traffic traffic-engine ((obj traffic-engine)) + (update-sync-from-frame-counter obj) + (per-frame-suppressor-update obj) + (let ((s5-0 (new 'stack-no-clear 'bounding-box))) + (set-vector! + (-> s5-0 min) + 10000000000000000000000000000000000000.0 + 10000000000000000000000000000000000000.0 + 10000000000000000000000000000000000000.0 + 1.0 + ) + (set-vector! + (-> s5-0 max) + -10000000000000000000000000000000000000.0 + -10000000000000000000000000000000000000.0 + -10000000000000000000000000000000000000.0 + 1.0 + ) + (dotimes (s4-0 2) + (let ((s3-0 (-> obj level-data-array s4-0))) + (when (nonzero? (-> s3-0 city-info)) + (per-frame-cell-update s3-0) + (add-box! s5-0 (-> s3-0 active-cell-box)) + 0 + ) + ) + ) + (update-grid-for-objects-in-box (-> obj object-hash) 253 (-> s5-0 min) (-> s5-0 max)) + ) + (per-frame-activate-deactivate obj) + (set! (-> obj alert-state guard-aim-count) 0) + (per-frame-alert-update obj) + (per-frame-guard-update obj) + (per-frame-danger-update obj) + 0 + (none) + ) + +(defmethod callback-on-nav-segments-in-sphere traffic-engine ((obj traffic-engine) + (arg0 vector) + (arg1 int) + (arg2 traffic-find-segment-struct) + (arg3 (function traffic-find-segment-struct nav-segment none)) + ) + (dotimes (s1-0 2) + (let ((v1-3 (-> obj level-data-array s1-0))) + (if (nonzero? (-> v1-3 city-info)) + (callback-on-nav-segments-in-sphere (-> v1-3 city-info) arg0 arg1 arg2 arg3) + ) + ) + ) + 0 + (none) + ) + +(deftype traffic-find-segment-struct (structure) + ((best-seg nav-segment :offset-assert 0) + (best-rating float :offset-assert 4) + (dir vector :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + + +(defmethod find-best-segment traffic-engine ((obj traffic-engine) (arg0 vector) (arg1 vector) (arg2 int)) + (let ((gp-0 (new 'stack-no-clear 'traffic-find-segment-struct))) + (set! (-> gp-0 dir quad) (-> arg1 quad)) + (set! (-> gp-0 best-rating) -10000000000000000000000000000000000000.0) + (set! (-> gp-0 best-seg) #f) + (callback-on-nav-segments-in-sphere + obj + arg0 + arg2 + gp-0 + (lambda ((arg0 traffic-find-segment-struct) (arg1 nav-segment)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (vector-! v1-0 (-> arg1 vertex 1) (the-as vector (-> arg1 vertex))) + (let ((a2-1 v1-0) + (a3-1 v1-0) + (f0-0 (-> arg1 length)) + ) + (vector-float*! a2-1 a3-1 (/ 1.0 f0-0)) + ) + (let ((f0-4 (vector-dot v1-0 (-> arg0 dir)))) + (when (< (-> arg0 best-rating) f0-4) + (set! (-> arg0 best-rating) f0-4) + (set! (-> arg0 best-seg) arg1) + ) + ) + ) + (none) + ) + ) + (-> gp-0 best-seg) + ) + ) + +(defmethod maybe-increase-guard-aim-count traffic-engine ((obj traffic-engine)) + (when (< (-> obj alert-state guard-aim-count) 2) + (+! (-> obj alert-state guard-aim-count) 1) + #t + ) + ) + +(defmethod increase-alert-level traffic-engine ((obj traffic-engine) (arg0 int) (arg1 target)) + (with-pp + (when (and (logtest? (-> obj alert-state flags) (traffic-alert-flag target-jak)) + (logtest? (-> arg1 mask) (process-mask target)) + ) + (let ((v1-6 (min arg0 (the-as int (-> obj alert-state max-level))))) + (when #t + (set! (-> obj alert-state start-time) (-> pp clock frame-counter)) + (logclear! (-> obj alert-state flags) (traffic-alert-flag alert-ending)) + ) + (set! (-> obj alert-state level) (the-as uint (max (the-as int (-> obj alert-state level)) v1-6))) + ) + ) + 0 + (none) + ) + ) + +(defmethod decrease-alert-level traffic-engine ((obj traffic-engine) (arg0 int)) + (if (logtest? (-> obj alert-state flags) (traffic-alert-flag target-jak)) + (set! (-> obj alert-state level) (the-as uint (min (the-as int (-> obj alert-state level)) arg0))) + ) + 0 + (none) + ) + +(defmethod set-alert-level traffic-engine ((obj traffic-engine) (arg0 int)) + (with-pp + (set! (-> obj alert-state level) (the-as uint arg0)) + (set! (-> obj alert-state start-time) (-> pp clock frame-counter)) + (logclear! (-> obj alert-state flags) (traffic-alert-flag alert-ending)) + 0 + (none) + ) + ) + +(defmethod set-max-alert-level traffic-engine ((obj traffic-engine) (arg0 int)) + (set! (-> obj alert-state max-level) (the-as uint arg0)) + (set! (-> obj alert-state level) (the-as uint (min (the-as int (-> obj alert-state level)) arg0))) + 0 + (none) + ) + +;; WARN: Return type mismatch uint vs int. +(defmethod get-alert-level traffic-engine ((obj traffic-engine)) + (the-as int (-> obj alert-state level)) + ) + +(defmethod get-target traffic-engine ((obj traffic-engine)) + "@returns [[*target*]]" + *target* + ) + +(defun traffic-los-clear? ((arg0 vector) (arg1 vector)) + (let ((v1-0 (new 'stack-no-clear 'collide-query))) + (set! (-> v1-0 start-pos quad) (-> arg0 quad)) + (vector-! (-> v1-0 move-dist) arg1 arg0) + (let ((a0-1 v1-0)) + (set! (-> a0-1 radius) 2048.0) + (set! (-> a0-1 collide-with) (collide-spec backgnd)) + (set! (-> a0-1 ignore-process0) #f) + (set! (-> a0-1 ignore-process1) #f) + (set! (-> a0-1 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> a0-1 action-mask) (collide-action solid)) + ) + (< (fill-and-probe-using-line-sphere *collide-cache* v1-0) 0.0) + ) + ) + +(define *guard-target-spots* (new 'static 'boxed-array :type vector + (new 'static 'vector :x 20480.0 :w 1.0) + (new 'static 'vector :x 14481.408 :z -14481.408 :w 1.0) + (new 'static 'vector :z -20480.0 :w 1.0) + (new 'static 'vector :x -14481.408 :z -14481.408 :w 1.0) + (new 'static 'vector :x -20480.0 :w 1.0) + (new 'static 'vector :x -14481.408 :z 14481.408 :w 1.0) + (new 'static 'vector :z 20480.0 :w 1.0) + (new 'static 'vector :x 14481.408 :z 14481.408 :w 1.0) + (new 'static 'vector :x 28672.0 :w 1.0) + (new 'static 'vector :x 24831.182 :z -14335.181 :w 1.0) + (new 'static 'vector :x 14336.409 :z -24829.543 :w 1.0) + (new 'static 'vector :z -28672.0 :w 1.0) + (new 'static 'vector :x -14333.952 :z -24831.182 :w 1.0) + (new 'static 'vector :x -24829.951 :z -14336.409 :w 1.0) + (new 'static 'vector :x -28672.0 :w 1.0) + (new 'static 'vector :x -24830.771 :z 14333.952 :w 1.0) + (new 'static 'vector :x -14337.229 :z 24829.951 :w 1.0) + (new 'static 'vector :z 28672.0 :w 1.0) + (new 'static 'vector :x 14335.181 :z 24830.771 :w 1.0) + (new 'static 'vector :x 24829.543 :z 14337.229 :w 1.0) + ) + ) + +(define *guard-id-spots* (new 'static 'boxed-array :type int32 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + ) + ) + +(define *guard-status-spots* (new 'static 'boxed-array :type int32 :length 0 :allocated-length 32)) + +(defun update-guard-status-spots ((arg0 vector)) + (local-vars (v0-1 symbol)) + (let ((s5-0 (find-nearest-nav-mesh arg0 (the-as float #x7f800000))) + (v1-0 (new 'stack-no-clear 'vector)) + ) + (new 'stack-no-clear 'vector) + (let ((s4-0 (new 'stack-no-clear 'nav-find-poly-parms))) + (if (or (not s5-0) (zero? s5-0)) + (return #f) + ) + (when s5-0 + (vector-! v1-0 arg0 (-> s5-0 bounds)) + (set! (-> s4-0 y-threshold) 40960.0) + (set! (-> s4-0 ignore) (the-as uint 2)) + (dotimes (s3-0 8) + (vector+! (-> s4-0 point) arg0 (-> *guard-target-spots* s3-0)) + (vector-! (-> s4-0 point) (-> s4-0 point) (-> s5-0 bounds)) + (cond + ((find-poly-containing-point-local s5-0 s4-0) + (vector+! (-> s4-0 point) (-> s4-0 point) (-> s5-0 bounds)) + (set! (-> *guard-status-spots* s3-0) 1) + ) + (else + (set! (-> *guard-status-spots* s3-0) 0) + 0 + ) + ) + ) + ) + ) + ) + (return #t) + v0-1 + ) + +;; WARN: Return type mismatch object vs none. +(defun generate-target-spots () + "Code-gen function to define [[*guard-target-spots*]] using [[*x-vector*]]" + (format #t "(define *guard-target-spots* (new 'static 'array 'vector 0~%") + (dotimes (gp-0 8) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (vector-rotate-around-y! s5-0 *x-vector* (* 182.04445 (* 45.0 (the float gp-0)))) + (vector-float*! s5-0 s5-0 20480.0) + (format + #t + " (new 'static 'vector :x (meters ~M) :y (meters ~M) :z (meters ~M) :w 1.0)~%" + (-> s5-0 x) + (-> s5-0 y) + (-> s5-0 z) + ) + ) + ) + (dotimes (gp-1 12) + (let ((s5-1 (new 'stack-no-clear 'vector))) + (vector-rotate-around-y! s5-1 *x-vector* (* 182.04445 (* 30.0 (the float gp-1)))) + (vector-float*! s5-1 s5-1 28672.0) + (format + #t + " (new 'static 'vector :x (meters ~M) :y (meters ~M) :z (meters ~M) :w 1.0)~%" + (-> s5-1 x) + (-> s5-1 y) + (-> s5-1 z) + ) + ) + ) + (format #t " )~%") + (format #t " )~%") + (none) + ) + +(defmethod find-closest-to-with-collide-lists traffic-engine ((obj traffic-engine) (arg0 process-drawable) (arg1 collide-spec)) + "Iterate through collide lists, find the closest thing to the given process." + (let ((gp-0 (the-as process-focusable #f))) + (let ((f30-0 (the-as float #x7f800000))) + (when (logtest? arg1 (collide-spec player-list)) + (let ((v1-4 (-> *collide-player-list* alive-list next0))) + *collide-player-list* + (let ((s3-0 (-> v1-4 next0))) + (while (!= v1-4 (-> *collide-player-list* alive-list-end)) + (let ((v1-5 (the-as collide-shape (-> (the-as connection v1-4) param1)))) + (when (logtest? arg1 (-> v1-5 root-prim prim-core collide-as)) + (let* ((s1-0 (-> v1-5 process)) + (s2-0 (if (type? s1-0 process-focusable) + (the-as process-focusable s1-0) + ) + ) + ) + (when (and s2-0 (not (logtest? (-> s2-0 focus-status) (focus-status disable dead inactive))) (!= arg0 s2-0)) + (let ((f0-0 (vector-vector-xz-distance (-> arg0 root trans) (-> s2-0 root-override trans)))) + (when (or (not gp-0) (< f0-0 f30-0)) + (set! gp-0 s2-0) + (set! f30-0 f0-0) + ) + ) + ) + ) + ) + ) + (set! v1-4 s3-0) + *collide-player-list* + (set! s3-0 (-> s3-0 next0)) + ) + ) + ) + ) + (when (logtest? arg1 (collide-spec hit-by-player-list hit-by-others-list)) + (when (logtest? arg1 (collide-spec hit-by-player-list)) + (let ((v1-22 (-> *collide-hit-by-player-list* alive-list next0))) + *collide-hit-by-player-list* + (let ((s3-1 (-> v1-22 next0))) + (while (!= v1-22 (-> *collide-hit-by-player-list* alive-list-end)) + (let ((v1-23 (the-as collide-shape (-> (the-as connection v1-22) param1)))) + (when (logtest? arg1 (-> v1-23 root-prim prim-core collide-as)) + (let* ((s1-1 (-> v1-23 process)) + (s2-1 (if (type? s1-1 process-focusable) + (the-as process-focusable s1-1) + ) + ) + ) + (when (and s2-1 (not (logtest? (-> s2-1 focus-status) (focus-status disable dead inactive))) (!= arg0 s2-1)) + (let ((f0-1 (vector-vector-xz-distance (-> arg0 root trans) (-> s2-1 root-override trans)))) + (when (or (not gp-0) (< f0-1 f30-0)) + (set! gp-0 s2-1) + (set! f30-0 f0-1) + ) + ) + ) + ) + ) + ) + (set! v1-22 s3-1) + *collide-hit-by-player-list* + (set! s3-1 (-> s3-1 next0)) + ) + ) + ) + ) + (when (logtest? arg1 (collide-spec hit-by-others-list)) + (let ((v1-38 (-> *collide-hit-by-others-list* alive-list next0))) + *collide-hit-by-others-list* + (let ((s3-2 (-> v1-38 next0))) + (while (!= v1-38 (-> *collide-hit-by-others-list* alive-list-end)) + (let ((v1-39 (the-as collide-shape (-> (the-as connection v1-38) param1)))) + (when (logtest? arg1 (-> v1-39 root-prim prim-core collide-as)) + (let* ((s1-2 (-> v1-39 process)) + (s2-2 (if (type? s1-2 process-focusable) + (the-as process-focusable s1-2) + ) + ) + ) + (when (and s2-2 (not (logtest? (-> s2-2 focus-status) (focus-status disable dead inactive))) (!= arg0 s2-2)) + (let ((f0-2 (vector-vector-xz-distance (-> arg0 root trans) (-> s2-2 root-override trans)))) + (when (or (not gp-0) (< f0-2 f30-0)) + (set! gp-0 s2-2) + (set! f30-0 f0-2) + ) + ) + ) + ) + ) + ) + (set! v1-38 s3-2) + *collide-hit-by-others-list* + (set! s3-2 (-> s3-2 next0)) + ) + ) + ) + ) + ) + ) + gp-0 + ) + ) + +(defmethod traffic-engine-method-49 traffic-engine ((obj traffic-engine) (arg0 object) (arg1 int) (arg2 traffic-target-status)) + (local-vars (sv-192 (pointer crimson-guard)) (sv-196 (pointer float)) (sv-200 int) (sv-208 int) (sv-216 float)) + (with-pp + (logclear! (-> arg2 flags) (traffic-target-flag visible-now updated)) + (cond + ((= (-> obj sync-mask-16) (ash 1 (logand arg1 15))) + (logior! (-> arg2 flags) (traffic-target-flag updated)) + (let ((s3-0 (handle->process (-> arg2 handle))) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (when s3-0 + (set! (-> s5-0 quad) (-> (get-trans (the-as process-focusable s3-0) 3) quad)) + (cond + ((= (-> (the-as process-focusable s3-0) type) target) + (let ((s1-1 (-> obj alert-state target-status-array))) + (logclear! (-> s1-1 0 flags) (traffic-target-flag visible-now updated)) + (logior! (-> s1-1 0 flags) (traffic-target-flag updated)) + (cond + ((or (logtest? (-> s1-1 0 flags) (traffic-target-flag force-visible)) + (traffic-los-clear? (the-as vector arg0) s5-0) + ) + (logior! (-> s1-1 0 flags) (traffic-target-flag visible-now visible-recently visible-ever)) + (set! (-> s1-1 0 last-seen-time) (-> pp clock frame-counter)) + (set! (-> s1-1 0 position quad) (-> s5-0 quad)) + (set! (-> s1-1 0 velocity quad) (-> (get-transv (the-as process-focusable s3-0)) quad)) + ) + (else + (if (>= (- (-> pp clock frame-counter) (-> s1-1 0 last-seen-time)) (seconds 2)) + (logclear! (-> s1-1 0 flags) (traffic-target-flag visible-recently)) + ) + ) + ) + (mem-copy! (the-as pointer arg2) (the-as pointer s1-1) 80) + ) + 0 + ) + (else + (logior! (-> arg2 flags) (traffic-target-flag visible-now visible-recently visible-ever)) + (set! (-> arg2 last-seen-time) (-> pp clock frame-counter)) + (set! (-> arg2 position quad) (-> s5-0 quad)) + (set! (-> arg2 velocity quad) (-> (get-transv (the-as process-focusable s3-0)) quad)) + ) + ) + (set! (-> s5-0 quad) (-> arg2 position quad)) + (when (not (update-guard-status-spots s5-0)) + ) + (when (update-guard-status-spots s5-0) + (set! sv-192 (new 'stack-no-clear 'array 'crimson-guard 16)) + (set! sv-196 (new 'stack-no-clear 'array 'float 16)) + (set! sv-200 0) + (dotimes (s3-1 (the-as int (-> obj vehicle-tracker-array active-object-count))) + (case (-> obj vehicle-tracker-array active-object-type-list s3-1) + (((traffic-type crimson-guard-1)) + (let ((s2-3 (handle->process (-> obj vehicle-tracker-array active-object-list s3-1)))) + (when (and s2-3 + (not (logtest? (-> (the-as process-focusable s2-3) focus-status) (focus-status dead inactive))) + (= (-> (the-as crimson-guard s2-3) traffic-target-status handle) (-> arg2 handle)) + ) + (set! (-> sv-192 sv-200) (the-as crimson-guard s2-3)) + (set! (-> sv-196 sv-200) (vector-vector-distance (-> (the-as crimson-guard s2-3) root-override2 trans) s5-0)) + (set! sv-200 (+ sv-200 1)) + (set! (-> (the-as crimson-guard s2-3) move-index) -1) + ) + ) + ) + ) + ) + (let ((a0-35 #t)) + (while a0-35 + (set! a0-35 #f) + (dotimes (v1-77 (+ sv-200 -1)) + (when (< (-> sv-196 (+ v1-77 1)) (-> sv-196 v1-77)) + (let ((a0-38 (-> sv-192 v1-77)) + (f0-2 (-> sv-196 v1-77)) + ) + (set! (-> sv-192 v1-77) (-> sv-192 (+ v1-77 1))) + (set! (-> sv-192 (+ v1-77 1)) a0-38) + (set! (-> sv-196 v1-77) (-> sv-196 (+ v1-77 1))) + (set! (-> sv-196 (+ v1-77 1)) f0-2) + ) + (set! a0-35 #t) + ) + ) + ) + ) + (dotimes (s4-1 sv-200) + (let ((s3-2 (-> (the-as (array crimson-guard) sv-192) s4-1))) + (when (= (-> s3-2 move-index) -1) + (set! sv-208 -1) + (set! sv-216 100000000000000000.0) ;; kinda hacky, was ps2 weird infinity. + (dotimes (s2-4 (-> *guard-target-spots* length)) + (when (= (-> *guard-status-spots* s2-4) 1) + (let* ((a0-53 (vector+! (new 'stack-no-clear 'vector) s5-0 (-> *guard-target-spots* s2-4))) + (f0-4 (vector-vector-distance a0-53 (-> s3-2 root-override2 trans))) + ) + (when (or (= sv-208 -1) (< f0-4 sv-216)) + (set! sv-208 s2-4) + (set! sv-216 f0-4) + ) + ) + ) + ) + (cond + ((!= sv-208 -1) + (set! (-> *guard-status-spots* sv-208) 0) + (vector+! (-> s3-2 move-position) s5-0 (-> *guard-target-spots* sv-208)) + ) + (else + (set! (-> s3-2 move-position quad) (-> s5-0 quad)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (else + (let ((s5-1 (handle->process (-> arg2 handle))) + (s3-3 (new 'stack-no-clear 'vector)) + ) + (when s5-1 + (set! (-> s3-3 quad) (-> (get-trans (the-as process-focusable s5-1) 3) quad)) + (cond + ((= (-> s5-1 type) target) + (mem-copy! (the-as pointer arg2) (the-as pointer (-> obj alert-state target-status-array)) 80) + ) + (else + ) + ) + ) + ) + (logclear! (-> arg2 flags) (traffic-target-flag updated)) + ) + ) + arg2 + ) + ) + +(defmethod set-alert-duration traffic-engine ((obj traffic-engine) (arg0 int)) + (set! (-> obj alert-state duration) (the-as uint arg0)) + 0 + (none) + ) + +(defmethod guard-count traffic-engine ((obj traffic-engine)) + (let ((v0-0 0)) + (dotimes (v1-0 6) + (+! v0-0 (-> obj alert-state guard-type-info-array v1-0 count)) + ) + v0-0 + ) + ) + +(defmethod end-pursuit-by-type traffic-engine ((obj traffic-engine) (arg0 traffic-type)) + (for-all-active-processes-of-type + (-> obj tracker-array (-> obj object-type-info-array arg0 tracker-index)) + arg0 + (the-as + (function process-focusable traffic-object-type-info none) + (lambda ((arg0 process-tree)) (send-event arg0 'end-pursuit) (none)) + ) + ) + 0 + (none) + ) + +(defmethod set-target-level traffic-engine ((obj traffic-engine) (arg0 float)) + (set! (-> obj alert-state guard-target-level) arg0) + (dotimes (v1-0 21) + (let ((a2-2 (-> obj object-type-info-array v1-0))) + (set! (-> a2-2 target-count) (the int (* arg0 (the float (max 0 (+ (-> a2-2 want-count) -1)))))) + ) + ) + 0 + (none) + ) + +(defmethod set-guard-target-level traffic-engine ((obj traffic-engine) (arg0 float)) + (set! (-> obj alert-state guard-target-level) arg0) + 0 + (none) + ) + +(define *alert-level-settings* (new 'static 'traffic-alert-state-settings + :ped-tazer (new 'static 'traffic-guard-type-settings + :target-count 5 + :inaccuracy 0.5 + :acquire-delay #x12c + :shot-delay #x4b + :burst-delay #x258 + :shot-count 1 + ) + :ped-rifle (new 'static 'traffic-guard-type-settings + :inaccuracy 0.5 + :acquire-delay #x12c + :shot-delay #x4b + :burst-delay #x258 + :shot-count 2 + :rand-shot-count 1 + ) + :ped-grenade (new 'static 'traffic-guard-type-settings + :inaccuracy 0.5 + :acquire-delay #x12c + :shot-delay #x4b + :burst-delay #x258 + :shot-count 1 + ) + :ped-roboguard (new 'static 'traffic-guard-type-settings + :inaccuracy 0.5 + :acquire-delay #x12c + :shot-delay #x4b + :burst-delay #x258 + :shot-count 1 + ) + :bike-turret (new 'static 'traffic-guard-type-settings + :target-count 1 + :inaccuracy 0.5 + :acquire-delay #x12c + :shot-delay #x4b + :burst-delay #x5dc + :shot-count 2 + :rand-shot-count 1 + ) + :hellcat-turret (new 'static 'traffic-guard-type-settings + :target-count 1 + :inaccuracy 0.5 + :acquire-delay #x12c + :shot-delay #x4b + :burst-delay #x5dc + :shot-count 2 + :rand-shot-count 1 + ) + ) + ) + +(defmethod get-traffic-guard-type-settings traffic-engine ((obj traffic-engine) (arg0 int)) + "TODO - guard-type should be an enum" + (-> obj alert-state settings guard-settings-array arg0) + ) + +(defmethod get-guard-type-for-traffic-obj traffic-engine ((obj traffic-engine) (arg0 int)) + "TODO - guard-type should be an enum" + (-> obj object-type-info-array arg0 guard-type) + ) + +(defmethod get-traffic-guard-change-to-type traffic-engine ((obj traffic-engine) (arg0 int)) + "TODO - guard-type should be an enum" + (-> obj alert-state guard-type-info-array arg0 change-to-type) + ) + +(defmethod per-frame-guard-update traffic-engine ((obj traffic-engine)) + (dotimes (v1-0 6) + (set! (-> obj alert-state guard-type-info-array v1-0 count) 0) + ) + (let* ((f0-0 122880.0) + (f0-2 (* f0-0 f0-0)) + (a0-3 (the-as vehicle #f)) + (v1-5 0) + ) + (let ((a1-0 0)) + (dotimes (a2-0 (the-as int (-> obj citizen-tracker-array active-object-count))) + (case (-> obj citizen-tracker-array active-object-type-list a2-0) + (((traffic-type guard-bike) (traffic-type hellcat)) + (let ((a3-6 (handle->process (-> obj citizen-tracker-array active-object-list a2-0)))) + (when (and a3-6 + (not (logtest? (-> (the-as vehicle a3-6) focus-status) (focus-status dead inactive))) + (logtest? (rigid-body-object-flag alert) (-> (the-as vehicle a3-6) flags)) + ) + (let ((t0-13 (-> (the-as vehicle a3-6) info-override guard-type))) + (+! (-> obj alert-state guard-type-info-array t0-13 count) 1) + ) + (when (and (logtest? (rigid-body-object-flag in-pursuit) (-> (the-as vehicle a3-6) flags)) + (logtest? (rigid-body-object-flag target-in-sight) (-> (the-as vehicle a3-6) flags)) + ) + (+! a1-0 1) + (when (not (logtest? (-> (the-as vehicle a3-6) draw status) (draw-control-status on-screen))) + (+! v1-5 1) + (let ((f1-0 (-> (the-as vehicle a3-6) target-distance2))) + (when (< f0-2 f1-0) + (set! f0-2 f1-0) + (set! a0-3 (the-as vehicle a3-6)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (set! (-> obj alert-state guards-in-sight-of-target) a1-0) + ) + (when (< 2 v1-5) + (if (not (logtest? (-> obj alert-state flags) (traffic-alert-flag disable-pursuit-control))) + (send-event a0-3 'end-pursuit) + ) + ) + ) + (let ((f30-0 122880.0) + (s5-0 (the-as crimson-guard #f)) + (s4-0 0) + ) + (let ((s3-0 0)) + (let ((s2-0 0)) + (dotimes (s1-0 (the-as int (-> obj vehicle-tracker-array active-object-count))) + (case (-> obj vehicle-tracker-array active-object-type-list s1-0) + (((traffic-type crimson-guard-1)) + (let ((s0-0 (handle->process (-> obj vehicle-tracker-array active-object-list s1-0)))) + (when (and s0-0 (zero? (logand (-> (the-as crimson-guard s0-0) focus-status) (focus-status dead inactive)))) + (when (and (logtest? (-> (the-as crimson-guard s0-0) flags) (citizen-flag in-pursuit)) + (logtest? (-> (the-as crimson-guard s0-0) flags) (citizen-flag target-in-sight)) + ) + (+! s3-0 1) + (when (not (logtest? (-> (the-as crimson-guard s0-0) draw status) (draw-control-status on-screen))) + (+! s4-0 1) + (let ((f0-3 (-> (the-as crimson-guard s0-0) target-self-dist))) + (when (< f30-0 f0-3) + (set! f30-0 f0-3) + (set! s5-0 (the-as crimson-guard s0-0)) + ) + (if (and (< 327680.0 f0-3) + (zero? (logand (-> obj alert-state flags) (traffic-alert-flag disable-pursuit-control))) + ) + (send-event (the-as crimson-guard s0-0) 'end-pursuit) + ) + ) + ) + ) + (let ((v1-42 (-> s0-0 stack 860))) + (when (< v1-42 (the-as uint 6)) + (+! s2-0 1) + (+! (-> obj alert-state guard-type-info-array v1-42 count) 1) + ) + ) + ) + ) + ) + ) + ) + ) + (+! (-> obj alert-state guards-in-sight-of-target) s3-0) + ) + (when (< 2 s4-0) + (if (not (logtest? (-> obj alert-state flags) (traffic-alert-flag disable-pursuit-control))) + (send-event s5-0 'end-pursuit) + ) + ) + ) + (let ((v1-58 -1) + (a0-25 -1) + ) + (let ((a1-6 0) + (a2-4 9) + ) + (dotimes (a3-9 6) + (when (= (-> obj alert-state guard-type-info-array a3-9 object-type) (traffic-type crimson-guard-1)) + (let ((t1-15 (-> obj alert-state guard-type-info-array a3-9))) + (set! (-> t1-15 change-to-type) (the-as uint a3-9)) + (let ((t0-33 (- (-> t1-15 target-count) (-> t1-15 count)))) + (when (< a1-6 t0-33) + (set! v1-58 a3-9) + (set! a1-6 t0-33) + ) + (when (and (< t0-33 a2-4) (> (-> t1-15 count) 0)) + (set! a0-25 a3-9) + (set! a2-4 t0-33) + ) + ) + ) + ) + ) + ) + (when (and (!= v1-58 -1) (!= a0-25 -1)) + (set! (-> obj alert-state guard-type-info-array a0-25 change-to-type) (the-as uint v1-58)) + (set! (-> obj object-type-info-array 6 guard-type) (the-as uint v1-58)) + ) + ) + 0 + (none) + ) + +(defmethod per-frame-alert-update traffic-engine ((obj traffic-engine)) + (with-pp + (if (and (logtest? (-> obj alert-state flags) (traffic-alert-flag target-jak)) *target*) + (set! (-> obj alert-state target-status-array 0 handle) (process->handle *target*)) + ) + (when #t + (mem-copy! + (the-as pointer (-> obj alert-state settings)) + (the-as pointer (+ (the-as uint *alert-level-settings*) (* (the-as uint 96) (-> obj alert-state level)))) + 96 + ) + (dotimes (v1-10 6) + (let ((a1-3 (-> obj alert-state settings guard-settings-array v1-10)) + (a0-10 (-> obj alert-state guard-type-info-array v1-10)) + ) + (set! (-> a1-3 inaccuracy) + (fmax 0.0 (fmin 1.0 (* (-> a1-3 inaccuracy) (-> obj alert-state guard-inaccuracy-factor)))) + ) + (when *target* + (when (logtest? (focus-status pilot) (-> *target* focus-status)) + (set! (-> a1-3 acquire-delay) (the-as uint (the int (* 0.75 (the float (-> a1-3 acquire-delay)))))) + (set! (-> a1-3 shot-delay) (the-as uint (the int (* 0.6 (the float (-> a1-3 shot-delay)))))) + (set! (-> a1-3 burst-delay) (the-as uint (the int (* 0.8 (the float (-> a1-3 burst-delay)))))) + ) + ) + (set! (-> a0-10 target-count) + (max + (min + (the int (* (the float (-> a1-3 target-count)) (-> obj alert-state guard-target-level))) + (-> a0-10 max-target-count) + ) + (-> a0-10 min-target-count) + ) + ) + ) + ) + ) + (dotimes (v1-13 21) + (let ((a1-8 (-> obj alert-state guard-type-mask-from-object-type v1-13))) + (when (nonzero? a1-8) + (let ((a2-18 0) + (a0-14 0) + ) + (while (nonzero? a1-8) + (if (logtest? a1-8 1) + (+! a0-14 (-> obj alert-state guard-type-info-array a2-18 target-count)) + ) + (+! a2-18 1) + (set! a1-8 (shr a1-8 1)) + ) + (set! (-> obj object-type-info-array v1-13 target-count) a0-14) + ) + ) + ) + ) + (let ((s5-0 #f)) + (when *traffic-alert-level-force* + (set! (-> obj alert-state level) (the-as uint 3)) + (logclear! (-> obj alert-state flags) (traffic-alert-flag alert-ending)) + (set! (-> obj alert-state start-time) (-> pp clock frame-counter)) + ) + (when (>= (-> obj alert-state level) (the-as uint 1)) + (set! s5-0 #t) + (cond + ((logtest? (-> obj alert-state flags) (traffic-alert-flag alert-ending)) + (cond + ((> (guard-count obj) 0) + (set! (-> obj alert-state start-time) (-> pp clock frame-counter)) + ) + (else + (when (>= (- (-> pp clock frame-counter) (-> obj alert-state start-time)) (seconds 3)) + (set! s5-0 #f) + (set! (-> obj alert-state level) (the-as uint 0)) + (logclear! (-> obj alert-state flags) (traffic-alert-flag alert-ending)) + ) + ) + ) + ) + (else + (let ((v1-39 (+ (- (-> obj alert-state start-time) (-> pp clock frame-counter)) + (the-as time-frame (-> obj alert-state duration)) + ) + ) + ) + (if (and *target* (-> *target* next-state) (= (-> *target* next-state name) 'target-hide)) + (set! v1-39 (- v1-39 (the-as time-frame (* (- (-> pp clock frame-counter) (-> *target* state-time)) 2)))) + ) + (if (> v1-39 0) + 0 + (logior! (-> obj alert-state flags) (traffic-alert-flag alert-ending)) + ) + ) + ) + ) + ) + (cond + (s5-0 + (when (not (logtest? (-> obj alert-state flags) (traffic-alert-flag alarm-on))) + (logior! (-> obj alert-state flags) (traffic-alert-flag alarm-on)) + (set! (-> *game-info* wanted-flash) (the-as basic #t)) + (if (= (-> *setting-control* user-current music) 'city1) + (set-setting! 'sound-mode #f 0 1) + ) + ) + (let ((s5-1 (new 'stack-no-clear 'vector))) + (set! (-> s5-1 quad) (-> (target-pos 0) quad)) + (if (or (= (-> *setting-control* user-default music-volume) 0.0) + (!= (-> *setting-control* user-current music) 'city1) + ) + (sound-play "city-alarm" :id (-> obj alert-state alarm-sound-id) :position s5-1) + ) + ) + (if #t + (send-alert-events obj) + ) + (let ((v1-67 0)) + (dotimes (a0-45 21) + (let ((a1-19 (-> obj object-type-info-array a0-45))) + (if #t + (+! v1-67 (-> a1-19 killed-count)) + ) + ) + ) + (if (and (>= v1-67 (the-as int (* (-> obj alert-state level) 8))) + (< (-> obj alert-state level) (-> obj alert-state max-level)) + ) + (set-alert-level obj (the-as int (+ (-> obj alert-state level) 1))) + ) + ) + ) + (else + (when (logtest? (-> obj alert-state flags) (traffic-alert-flag alarm-on)) + (logclear! (-> obj alert-state flags) (traffic-alert-flag alarm-on)) + (set! (-> *game-info* wanted-flash) #f) + (remove-setting! 'sound-mode) + (sound-stop (-> obj alert-state alarm-sound-id)) + (send-alert-events obj) + (let ((v1-84 (-> obj alert-state target-status-array))) + (logclear! (-> v1-84 0 flags) (traffic-target-flag visible-now visible-recently visible-ever)) + ) + (dotimes (v1-85 21) + (set! (-> obj object-type-info-array v1-85 killed-count) (the-as uint 0)) + 0 + ) + ) + ) + ) + ) + 0 + (none) + ) + ) + +(defmethod send-alert-events traffic-engine ((obj traffic-engine)) + (with-pp + (set! (-> obj alert-state notify-time) (-> pp clock frame-counter)) + (cond + ((> (-> obj alert-state level) 0) + (if (and (logtest? (-> obj alert-state flags) (traffic-alert-flag target-jak)) + (not (logtest? (-> obj alert-state flags) (traffic-alert-flag alert-ending))) + *target* + ) + (for-all-active-processes obj (lambda ((arg0 process-focusable) (arg1 traffic-object-type-info)) + (if (logtest? (-> arg1 flags) 1) + (send-event arg0 'alert-begin *target*) + ) + (none) + ) + ) + ) + ) + (else + (for-all-active-processes obj (lambda ((arg0 process-focusable) (arg1 traffic-object-type-info)) + (if (logtest? (-> arg1 flags) 1) + (send-event arg0 'alert-end) + ) + (none) + ) + ) + ) + ) + 0 + (none) + ) + ) + +(defmethod restore-default-settings traffic-engine ((obj traffic-engine)) + (restore-city-speeches) + (logclear! + (-> obj alert-state flags) + (traffic-alert-flag guard-multi-focus sticky-guard-settings disable-pursuit-control) + ) + (set! (-> obj inv-density-factor) 5.0) + (if (demo?) + (set! (-> obj inv-density-factor) 1.25) + ) + (let ((v1-6 (-> obj alert-state target-status-array))) + (logclear! (-> v1-6 0 flags) (traffic-target-flag force-visible)) + ) + (set-target-level obj 1.0) + (set-alert-duration obj 9000) + (set-max-alert-level obj 4) + (let ((v1-13 42)) + (dotimes (a0-7 21) + (let ((a1-6 (-> obj object-type-info-array a0-7))) + (set! (-> a1-6 flags) (the-as uint 6)) + (set! (-> a1-6 reserve-count) (the-as uint (max 1000 (min #xfde8 (* 1000 (-> a1-6 want-count)))))) + (set! (-> a1-6 killed-count) (the-as uint 0)) + (set! (-> a1-6 parking-spot-prob) + (the-as uint (if (and (zero? (-> a1-6 tracker-index)) (zero? (logand (-> a1-6 flags) 1))) + v1-13 + 0 + ) + ) + ) + ) + ) + ) + (let ((v1-16 (-> obj object-type-info-array 6))) + (logior! (-> v1-16 flags) 1) + ) + (let ((v1-17 (-> obj object-type-info-array 7))) + (logior! (-> v1-17 flags) 1) + ) + (let ((v1-18 (-> obj object-type-info-array 18))) + (logior! (-> v1-18 flags) 1) + ) + (let ((v1-19 (-> obj object-type-info-array 19))) + (logior! (-> v1-19 flags) 1) + ) + (let ((v1-20 (-> obj object-type-info-array 20))) + (logior! (-> v1-20 flags) 1) + ) + (let ((v1-21 (-> obj object-type-info-array 5))) + (set! (-> v1-21 target-count) 0) + (set! (-> v1-21 flags) (logand -7 (-> v1-21 flags))) + ) + (let ((v1-22 (-> obj object-type-info-array 3))) + (set! (-> v1-22 target-count) 0) + (set! (-> v1-22 flags) (logand -5 (-> v1-22 flags))) + ) + (let ((v1-23 (-> obj object-type-info-array 4))) + (set! (-> v1-23 target-count) 0) + (set! (-> v1-23 flags) (logand -5 (-> v1-23 flags))) + ) + (let ((v1-24 (-> obj object-type-info-array 17))) + (set! (-> v1-24 target-count) 0) + (set! (-> v1-24 flags) (logand -7 (-> v1-24 flags))) + ) + (dotimes (v1-25 6) + (let ((a0-28 (-> obj alert-state guard-type-info-array v1-25))) + (set! (-> a0-28 min-target-count) 0) + (set! (-> a0-28 max-target-count) 127) + ) + ) + 0 + (none) + ) + +(defmethod deactivate-all traffic-engine ((obj traffic-engine)) + (deactivate-all (-> obj citizen-tracker-array) #t) + (deactivate-all (-> obj vehicle-tracker-array) #t) + 0 + (none) + ) + +(defmethod deactivate-by-type traffic-engine ((obj traffic-engine) (arg0 traffic-type)) + (let ((a2-0 (-> obj object-type-info-array arg0))) + (deactivate-all-of-type (-> obj tracker-array (-> a2-0 tracker-index)) arg0 #t) + ) + 0 + (none) + ) + +(defmethod deactivate-all-from-level traffic-engine ((obj traffic-engine) (arg0 symbol)) + (local-vars (v1-6 nav-branch)) + (countdown (s4-0 (-> obj citizen-tracker-array active-object-count)) + (let ((v1-3 (handle->process (-> obj citizen-tracker-array active-object-list s4-0)))) + (when v1-3 + (cond + ((logtest? (-> (the-as process-focusable v1-3) focus-status) (focus-status inactive)) + (deactivate-object (-> obj citizen-tracker-array) (the-as int s4-0) #f) + ) + ((begin (set! v1-6 (-> (the-as vehicle v1-3) controller branch)) (and v1-6 (nonzero? v1-6))) + (let ((v1-7 (-> v1-6 dest-node))) + (cond + (v1-7 + (if (= arg0 (-> v1-7 level)) + (deactivate-object (-> obj citizen-tracker-array) (the-as int s4-0) #t) + ) + ) + (else + 0 + ) + ) + ) + ) + (else + 0 + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod set-object-auto-activate traffic-engine ((obj traffic-engine) (arg0 int) (arg1 object)) + (let ((v1-2 (-> obj object-type-info-array arg0))) + (if arg1 + (logior! (-> v1-2 flags) 4) + (set! (-> v1-2 flags) (logand -5 (-> v1-2 flags))) + ) + ) + 0 + (none) + ) + +(defmethod set-object-target-level traffic-engine ((obj traffic-engine) (arg0 int) (arg1 float)) + (let ((v1-2 (-> obj object-type-info-array arg0))) + (set! (-> v1-2 target-count) (the int (* arg1 (the float (max 0 (+ (-> v1-2 want-count) -1)))))) + ) + 0 + (none) + ) + +(defmethod set-object-target-count traffic-engine ((obj traffic-engine) (arg0 int) (arg1 int)) + (set! (-> obj object-type-info-array arg0 target-count) arg1) + 0 + (none) + ) + +(defmethod set-guard-target-count-range traffic-engine ((obj traffic-engine) (arg0 int) (arg1 int) (arg2 int)) + (let ((v1-2 (-> obj alert-state guard-type-info-array arg0))) + (set! (-> v1-2 min-target-count) (max 0 (min 127 arg1))) + (set! (-> v1-2 max-target-count) (max 0 (min 127 arg2))) + ) + 0 + (none) + ) + +(defmethod set-object-reserve-count traffic-engine ((obj traffic-engine) (arg0 int) (arg1 uint)) + (set! (-> obj object-type-info-array arg0 reserve-count) arg1) + 0 + (none) + ) + +;; WARN: Return type mismatch uint vs int. +(defmethod get-object-reserve-count traffic-engine ((obj traffic-engine) (arg0 int)) + (the-as int (-> obj object-type-info-array arg0 reserve-count)) + ) + +(defmethod get-object-remaining-count traffic-engine ((obj traffic-engine) (arg0 int)) + (let ((a0-1 (-> obj object-type-info-array arg0))) + (+ (-> a0-1 active-count) (-> a0-1 reserve-count)) + ) + ) + +(defmethod set-parking-spot-prob traffic-engine ((obj traffic-engine) (arg0 int) (arg1 float)) + (let ((v1-2 (-> obj object-type-info-array arg0))) + (set! (-> v1-2 parking-spot-prob) (the-as uint (min 255 (the int (* 256.0 arg1))))) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch int vs traffic-type. +(defmethod get-random-parking-spot-type traffic-engine ((obj traffic-engine)) + (let ((s5-0 11)) + (let ((s4-0 (the int (* 256.0 (rand-vu)))) + (s3-0 0) + ) + (while (< (the-as uint s5-0) (the-as uint 21)) + (let ((s2-0 (-> obj object-type-info-array s5-0))) + (when (and (logtest? (-> s2-0 flags) 8) (= (level-status *level* (the-as symbol (-> s2-0 level))) 'active)) + (+! s3-0 (-> s2-0 parking-spot-prob)) + (b! (>= (the-as uint s3-0) (the-as uint s4-0)) cfg-10) + ) + ) + (+! s5-0 1) + ) + ) + (set! s5-0 21) + (label cfg-10) + (the-as traffic-type s5-0) + ) + ) + +(defmethod activate-object traffic-engine ((obj traffic-engine) (arg0 traffic-object-spawn-params)) + (let ((a2-0 (-> obj object-type-info-array (-> arg0 object-type)))) + (activate-from-params (-> obj tracker-array (-> a2-0 tracker-index)) arg0) + ) + 0 + (none) + ) + +(defmethod activate-by-handle traffic-engine ((obj traffic-engine) (arg0 traffic-object-spawn-params)) + (let ((a2-0 (-> obj object-type-info-array (-> arg0 object-type)))) + (activate-by-handle (-> obj tracker-array (-> a2-0 tracker-index)) arg0) + ) + 0 + (none) + ) + +(defmethod new-suppression-box traffic-engine ((obj traffic-engine) (arg0 traffic-suppression-params)) + (add-new-supression-box (-> obj suppressor) arg0) + (none) + ) + +(defmethod remove-suppression-box traffic-engine ((obj traffic-engine) (arg0 traffic-suppression-params)) + (remove-box-by-id (-> obj suppressor) (the-as int arg0)) + (none) + ) + +(defmethod update-suppression-box traffic-engine ((obj traffic-engine) (arg0 traffic-suppression-params)) + (update-box-from-params (-> obj suppressor) arg0) + (none) + ) + +(defmethod per-frame-suppressor-update traffic-engine ((obj traffic-engine)) + (let ((v1-3 (- (-> *display* game-clock frame-counter) (-> *display* game-clock old-frame-counter)))) + (dotimes (a1-3 16) + (let ((a2-2 (-> obj suppressor array a1-3))) + (when (logtest? (-> a2-2 flags) (traffic-suppression-box-flags in-use)) + (let ((a3-3 (the-as int (-> a2-2 duration)))) + (cond + ((< (the-as uint a3-3) (the-as uint v1-3)) + (logclear! (-> a2-2 flags) (traffic-suppression-box-flags in-use)) + (logior! (-> obj suppressor flags) (traffic-suppression-flags needs-update)) + ) + (else + (set! (-> a2-2 duration) (the-as uint (- (the-as time-frame a3-3) v1-3))) + ) + ) + ) + ) + ) + ) + ) + (when (logtest? (-> obj suppressor flags) (traffic-suppression-flags needs-update)) + (logclear! (-> obj suppressor flags) (traffic-suppression-flags needs-update)) + (recompute-supressions obj) + ) + 0 + (none) + ) + +(defmethod recompute-supressions traffic-engine ((obj traffic-engine)) + (dotimes (s5-0 2) + (let ((v1-3 (-> obj level-data-array s5-0))) + (if (nonzero? (-> v1-3 city-info)) + (update-suppressions-from-traffic-engine (-> v1-3 city-info) obj) + ) + ) + ) + 0 + (none) + ) + +(defmethod new traffic-engine ((allocation symbol) (type-to-make type)) + (let ((s5-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> s5-0 object-hash) ((method-of-type spatial-hash new) allocation spatial-hash #xc1c0 253)) + s5-0 + ) + ) + +(defmethod get-first-cell-in-box city-level-info ((obj city-level-info) (arg0 vis-grid-box)) + (-> obj + cell-array + (+ (-> arg0 min x) + (* (-> arg0 min z) (-> obj grid-info dimension-array 0)) + (* (* (-> arg0 min y) (-> obj grid-info dimension-array 0)) (-> obj grid-info dimension-array 2)) + ) + ) + ) + +(defmethod sphere-in-grid? city-level-info ((obj city-level-info) (arg0 int) (arg1 int)) + (let ((gp-0 #f)) + (let ((s3-0 (new 'stack-no-clear 'vis-grid-box)) + (s2-0 (new 'stack-no-clear 'vis-grid-box)) + ) + (lookup-box-for-sphere (-> obj grid-info) s2-0 (the-as vector arg0)) + (set! (-> s3-0 min y) (-> s2-0 min y)) + (let ((v1-6 (+ (- 1 (-> s2-0 min y)) (-> s2-0 max y)))) + (b! #t cfg-13 :delay (nop!)) + (label cfg-1) + (+! v1-6 -1) + (set! (-> s3-0 min z) (-> s2-0 min z)) + (let ((a0-7 (+ (- 1 (-> s2-0 min z)) (-> s2-0 max z)))) + (b! #t cfg-11 :delay (nop!)) + (label cfg-2) + (+! a0-7 -1) + (set! (-> s3-0 min x) (-> s2-0 min x)) + (let ((a1-7 (+ (- 1 (-> s2-0 min x)) (-> s2-0 max x)))) + (b! #t cfg-9 :delay (nop!)) + (label cfg-3) + (+! a1-7 -1) + (let ((a3-0 obj) + (t1-0 s3-0) + ) + (b! + (not (logtest? (-> a3-0 + cell-array + (+ (-> t1-0 min x) + (* (-> t1-0 min z) (-> a3-0 grid-info dimension-array 0)) + (* (* (-> t1-0 min y) (-> a3-0 grid-info dimension-array 0)) (-> a3-0 grid-info dimension-array 2)) + ) + flags + ) + (ash 1 arg1) + ) + ) + cfg-8 + :delay (empty-form) + ) + ) + (set! gp-0 #t) + (b! #t cfg-15 :delay (nop!)) + (label cfg-8) + (+! (-> s3-0 min x) 1) + (label cfg-9) + (b! (nonzero? a1-7) cfg-3 :delay (nop!)) + ) + (+! (-> s3-0 min z) 1) + (label cfg-11) + (b! (nonzero? a0-7) cfg-2 :delay (nop!)) + ) + (+! (-> s3-0 min y) 1) + (label cfg-13) + (b! (nonzero? v1-6) cfg-1 :delay (nop!)) + ) + ) + (label cfg-15) + gp-0 + ) + ) + +(defmethod callback-on-nav-segments-in-sphere city-level-info ((obj city-level-info) + (arg0 vector) + (arg1 int) + (arg2 traffic-find-segment-struct) + (arg3 (function traffic-find-segment-struct nav-segment none)) + ) + (local-vars + (sv-16 city-level-info) + (sv-20 vector) + (sv-24 int) + (sv-28 traffic-find-segment-struct) + (sv-32 (function traffic-find-segment-struct nav-segment none)) + (sv-80 vis-grid-box) + (sv-84 vis-grid-box) + ) + (set! sv-16 obj) + (set! sv-20 arg0) + (set! sv-24 arg1) + (set! sv-28 arg2) + (set! sv-32 arg3) + (set! sv-80 (new 'stack-no-clear 'vis-grid-box)) + (set! sv-84 (new 'stack-no-clear 'vis-grid-box)) + (lookup-box-for-sphere (-> sv-16 grid-info) sv-80 sv-20) + (set! (-> sv-84 min y) (-> sv-80 min y)) + (countdown (gp-0 (+ (- 1 (-> sv-80 min y)) (-> sv-80 max y))) + (set! (-> sv-84 min z) (-> sv-80 min z)) + (countdown (s5-0 (+ (- 1 (-> sv-80 min z)) (-> sv-80 max z))) + (set! (-> sv-84 min x) (-> sv-80 min x)) + (countdown (s4-0 (+ (- 1 (-> sv-80 min x)) (-> sv-80 max x))) + (let* ((a0-17 sv-16) + (a2-2 sv-84) + (v1-18 + (-> a0-17 + cell-array + (+ (-> a2-2 min x) + (* (-> a2-2 min z) (-> a0-17 grid-info dimension-array 0)) + (* (* (-> a2-2 min y) (-> a0-17 grid-info dimension-array 0)) (-> a0-17 grid-info dimension-array 2)) + ) + ) + ) + (s3-0 (-> v1-18 segment-array 0)) + ) + (countdown (s2-0 (-> v1-18 segment-count)) + (if (and (= (-> s3-0 tracker-id) sv-24) + (line-sphere-intersection? sv-20 (the-as vector (-> s3-0 vertex)) (-> s3-0 vertex 1)) + ) + (sv-32 sv-28 s3-0) + ) + (&+! s3-0 48) + ) + ) + (+! (-> sv-84 min x) 1) + ) + (+! (-> sv-84 min z) 1) + ) + (+! (-> sv-84 min y) 1) + ) + 0 + (none) + ) + +(defmethod update-suppressions-from-traffic-engine city-level-info ((obj city-level-info) (arg0 traffic-engine)) + (let ((v1-0 (-> obj cell-count))) + (dotimes (a0-1 (the-as int v1-0)) + (let ((a1-2 (-> obj cell-array a0-1))) + (logclear! (-> a1-2 flags) (vis-cell-flag suppress)) + ) + ) + ) + (let ((s4-0 (new 'stack-no-clear 'inline-array 'vis-grid-pos 2))) + (dotimes (s3-0 16) + (let ((s2-0 (-> arg0 suppressor array s3-0))) + (when (logtest? (-> s2-0 flags) (traffic-suppression-box-flags in-use)) + (lookup-cell-for-point (-> obj grid-info) (-> s4-0 1) (the-as vector (-> s2-0 bbox))) + (lookup-cell-for-point (-> obj grid-info) (-> s4-0 2) (-> s2-0 bbox max)) + (set! (-> s4-0 0 y) (-> s4-0 1 y)) + (countdown (v1-15 (+ (- 1 (-> s4-0 1 y)) (-> s4-0 2 y))) + (set! (-> s4-0 0 z) (-> s4-0 1 z)) + (countdown (a0-9 (+ (- 1 (-> s4-0 1 z)) (-> s4-0 2 z))) + (set! (-> s4-0 0 x) (-> s4-0 1 x)) + (countdown (a1-10 (+ (- 1 (-> s4-0 1 x)) (-> s4-0 2 x))) + (let* ((a3-1 obj) + (t1-0 (-> s4-0 0)) + (a2-8 (-> a3-1 + cell-array + (+ (-> t1-0 x) + (* (-> t1-0 z) (-> a3-1 grid-info dimension-array 0)) + (* (* (-> t1-0 y) (-> a3-1 grid-info dimension-array 0)) (-> a3-1 grid-info dimension-array 2)) + ) + ) + ) + ) + (logior! (-> a2-8 flags) (vis-cell-flag suppress)) + ) + (+! (-> s4-0 0 x) 1) + ) + (+! (-> s4-0 0 z) 1) + ) + (+! (-> s4-0 0 y) 1) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod add-active-cell traffic-level-data ((obj traffic-level-data) (arg0 vis-cell)) + (let ((v1-0 (-> obj active-cell-count))) + (when (< v1-0 (the-as uint 255)) + (set! (-> obj active-cell-list v1-0) arg0) + (+! (-> obj active-cell-count) 1) + ) + ) + 0 + (none) + ) + +(defmethod remove-active-cell traffic-level-data ((obj traffic-level-data) (arg0 int)) + (let ((v1-1 (+ (-> obj active-cell-count) -1))) + (when (>= v1-1 0) + (set! (-> obj active-cell-list arg0) (-> obj active-cell-list v1-1)) + (+! (-> obj active-cell-count) -1) + ) + ) + 0 + (none) + ) + +(defmethod add-newly-active-cell traffic-level-data ((obj traffic-level-data) (arg0 vis-cell)) + (let ((v1-0 (-> obj newly-active-cell-count))) + (when (< v1-0 (the-as uint 255)) + (set! (-> obj newly-active-cell-list v1-0) arg0) + (+! (-> obj newly-active-cell-count) 1) + ) + ) + 0 + (none) + ) + +(defmethod per-frame-cell-update traffic-level-data ((obj traffic-level-data)) + (set! (-> obj newly-active-cell-count) (the-as uint 0)) + (dotimes (v1-0 (the-as int (-> obj active-cell-count))) + (let ((a0-3 (-> obj active-cell-list v1-0))) + (set! (-> a0-3 prev-flags) (-> a0-3 flags)) + ) + ) + (let ((s5-0 (math-camera-pos)) + (f30-0 81920.0) + (f28-0 819200.0) + (f26-0 491520.0) + ) + (dotimes (s4-0 (the-as int (-> obj city-info cell-count))) + (let ((s3-0 (-> obj city-info cell-array s4-0))) + (let ((f24-0 (vector-vector-distance-squared (-> s3-0 sphere) s5-0)) + (f0-1 (+ (-> s3-0 sphere r) f28-0)) + ) + (cond + ((or (< (* f0-1 f0-1) f24-0) (let ((f0-5 (+ (-> s3-0 sphere r) f30-0))) + (and (< (* f0-5 f0-5) f24-0) (not (sphere-in-view-frustum? (-> s3-0 sphere)))) + ) + ) + (logclear! (-> s3-0 flags) (vis-cell-flag active-vehicle active-pedestrian)) + ) + ((let ((f0-9 (+ (-> s3-0 sphere r) f26-0))) + (< (* f0-9 f0-9) f24-0) + ) + (let ((v1-17 (logior (-> s3-0 flags) (vis-cell-flag active-vehicle)))) + (set! (-> s3-0 flags) (logclear v1-17 (vis-cell-flag active-pedestrian))) + ) + ) + (else + (logior! (-> s3-0 flags) (vis-cell-flag active-vehicle active-pedestrian)) + ) + ) + ) + (if (< (the-as uint (logand (-> s3-0 prev-flags) (vis-cell-flag active-vehicle active-pedestrian))) + (the-as uint (logand (-> s3-0 flags) (vis-cell-flag active-vehicle active-pedestrian))) + ) + (add-newly-active-cell obj s3-0) + ) + ) + ) + ) + (countdown (s5-1 (-> obj active-cell-count)) + (let ((v1-32 (-> obj active-cell-list s5-1))) + (when (not (logtest? (-> v1-32 flags) (vis-cell-flag active-vehicle active-pedestrian))) + (logclear! (-> v1-32 prev-flags) (vis-cell-flag active-vehicle active-pedestrian)) + (remove-active-cell obj (the-as int s5-1)) + ) + ) + ) + (dotimes (s5-2 (the-as int (-> obj newly-active-cell-count))) + (let ((a1-5 (-> obj newly-active-cell-list s5-2))) + (add-active-cell obj a1-5) + ) + ) + (let ((v1-43 (-> obj active-cell-box))) + (set-vector! + (-> v1-43 min) + 10000000000000000000000000000000000000.0 + 10000000000000000000000000000000000000.0 + 10000000000000000000000000000000000000.0 + 1.0 + ) + (set-vector! + (-> v1-43 max) + -10000000000000000000000000000000000000.0 + -10000000000000000000000000000000000000.0 + -10000000000000000000000000000000000000.0 + 1.0 + ) + (countdown (a0-23 (-> obj active-cell-count)) + (let ((a1-16 (-> obj active-cell-list a0-23))) + (set! (-> v1-43 min x) (fmin (-> v1-43 min x) (- (-> a1-16 sphere x) (-> a1-16 sphere r)))) + (set! (-> v1-43 min y) (fmin (-> v1-43 min y) (- (-> a1-16 sphere y) (-> a1-16 sphere r)))) + (set! (-> v1-43 min z) (fmin (-> v1-43 min z) (- (-> a1-16 sphere z) (-> a1-16 sphere r)))) + (set! (-> v1-43 max x) (fmax (-> v1-43 max x) (+ (-> a1-16 sphere x) (-> a1-16 sphere r)))) + (set! (-> v1-43 max y) (fmax (-> v1-43 max y) (+ (-> a1-16 sphere y) (-> a1-16 sphere r)))) + (set! (-> v1-43 max z) (fmax (-> v1-43 max z) (+ (-> a1-16 sphere z) (-> a1-16 sphere r)))) + ) + ) + ) + 0 + (none) + ) + +(defmethod lookup-cell-by-position city-level-info ((obj city-level-info) (arg0 vector)) + (let ((s5-0 (new 'stack-no-clear 'vis-grid-pos))) + (lookup-cell-for-point (-> obj grid-info) s5-0 arg0) + (-> obj + cell-array + (+ (-> s5-0 x) + (* (-> s5-0 z) (-> obj grid-info dimension-array 0)) + (* (* (-> s5-0 y) (-> obj grid-info dimension-array 0)) (-> obj grid-info dimension-array 2)) + ) + ) + ) + ) + +(defmethod init-vis-ray city-level-info ((obj city-level-info) (arg0 vis-ray) (arg1 vector) (arg2 vector)) + (set! (-> arg0 pos quad) (-> arg1 quad)) + (set! (-> arg0 dest-pos quad) (-> arg2 quad)) + (let ((v1-2 (new 'stack-no-clear 'vector))) + (vector-! v1-2 arg2 arg1) + (set! (-> arg0 len) (vector-length v1-2)) + (let ((a0-9 (-> arg0 dir)) + (f0-1 (-> arg0 len)) + ) + (vector-float*! a0-9 v1-2 (/ 1.0 f0-1)) + ) + ) + (lookup-cell-for-point (-> obj grid-info) (-> arg0 grid-pos) arg1) + (set! (-> arg0 cell) (lookup-cell-by-position obj arg1)) + 0 + (none) + ) + +(defmethod city-level-info-method-11 city-level-info ((obj city-level-info) (arg0 vis-ray)) + (local-vars (a3-3 int)) + (let ((f0-0 (-> arg0 len)) + (s4-0 -1) + ) + (dotimes (v1-0 2) + (let ((a0-1 (* v1-0 2)) + (a1-1 (new 'stack-no-clear 'vector)) + ) + (set! (-> a1-1 quad) (the-as uint128 0)) + (set! (-> a1-1 data a0-1) -1.0) + (let ((f1-1 (-> obj grid-info box min data a0-1)) + (a2-6 1) + ) + (let ((a3-2 (-> arg0 dir data a0-1))) + (shift-arith-right-32 a3-3 a3-2 31) + ) + (set! (-> a1-1 w) + (+ f1-1 + (* (the float (+ (- a2-6 (logand a3-3 1)) (-> (the-as (pointer int8) (+ a0-1 (the-as int arg0))) 64))) + (-> obj grid-info cell-size data a0-1) + ) + ) + ) + ) + (when (!= (-> arg0 dir data a0-1) 0.0) + (let ((f1-6 (/ (- (-> a1-1 w) (-> arg0 pos data a0-1)) (-> arg0 dir data a0-1)))) + (when (< f1-6 f0-0) + (set! f0-0 f1-6) + (set! s4-0 a0-1) + (set! (-> arg0 plane quad) (-> a1-1 quad)) + ) + ) + ) + ) + ) + (cond + ((= s4-0 -1) + (set! (-> arg0 pos quad) (-> arg0 dest-pos quad)) + (set! (-> arg0 len) 0.0) + ) + (else + (vector+float*! (-> arg0 pos) (-> arg0 pos) (-> arg0 dir) f0-0) + (set! (-> arg0 len) (vector-vector-distance (-> arg0 pos) (-> arg0 dest-pos))) + (+! (-> arg0 grid-pos data s4-0) (if (>= (-> arg0 dir data s4-0) 0.0) + 1 + -1 + ) + ) + (let ((a1-4 (-> arg0 grid-pos))) + (set! (-> arg0 cell) + (-> obj + cell-array + (+ (-> a1-4 x) + (* (-> a1-4 z) (-> obj grid-info dimension-array 0)) + (* (* (-> a1-4 y) (-> obj grid-info dimension-array 0)) (-> obj grid-info dimension-array 2)) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +(defmethod city-level-info-method-12 city-level-info ((obj city-level-info) (arg0 vector) (arg1 nav-branch) (arg2 vector)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((s2-0 (-> arg1 dest-node)) + (s3-0 #t) + (s5-0 (new 'stack-no-clear 'inline-array 'vector 7)) + ) + (let ((a1-1 s2-0) + (v1-0 (-> s5-0 2)) + ) + (set! (-> v1-0 quad) (-> a1-1 position quad)) + (set! (-> v1-0 w) 1.0) + ) + (let ((v1-1 s2-0) + (s1-0 (-> s5-0 3)) + ) + (let ((f0-2 (the float (-> v1-1 angle))) + (s0-0 (new 'stack-no-clear 'vector)) + ) + (sincos! s0-0 f0-2) + (set! (-> s1-0 x) (-> s0-0 y)) + (set! (-> s1-0 y) 0.0) + (set! (-> s1-0 z) (- (-> s0-0 x))) + ) + (set! (-> s1-0 w) 1.0) + ) + (vector-! (-> s5-0 5) (-> s5-0 2) arg0) + (set! (-> s5-0 4 quad) (-> s5-0 3 quad)) + (set! (-> s5-0 4 x) (-> s5-0 3 z)) + (set! (-> s5-0 4 z) (- (-> s5-0 3 x))) + (when (< 0.0 (vector-dot (-> s5-0 5) (-> s5-0 4))) + (set! s3-0 #f) + (vector-float*! (-> s5-0 4) (-> s5-0 4) -1.0) + ) + (let ((a1-8 (-> s5-0 6))) + (let ((v1-12 (-> s5-0 2))) + (let ((a0-9 (-> s5-0 4))) + (let* ((a2-1 s2-0) + (a2-4 (* 1024.0 (the float (-> a2-1 radius)))) + ) + (.mov vf7 a2-4) + ) + (.lvf vf5 (&-> a0-9 quad)) + ) + (.lvf vf4 (&-> v1-12 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-8 quad) vf6) + ) + (set! (-> s5-0 6 w) (* 1024.0 (the float (-> s2-0 radius)))) + (vector-! (-> s5-0 0) (-> s5-0 6) arg0) + (set! (-> s5-0 0 y) 0.0) + (let* ((v1-17 (-> s5-0 0)) + (f30-0 (sqrtf (+ (* (-> v1-17 x) (-> v1-17 x)) (* (-> v1-17 z) (-> v1-17 z))))) + (f28-0 (-> s5-0 6 w)) + ) + (vector-xz-normalize! (-> s5-0 0) 1.0) + (set! (-> s5-0 1 x) (-> s5-0 0 z)) + (set! (-> s5-0 1 y) 0.0) + (set! (-> s5-0 1 z) (- (-> s5-0 0 x))) + (if s3-0 + (vector-float*! (-> s5-0 1) (-> s5-0 1) -1.0) + ) + (let* ((f0-29 f30-0) + (f0-31 (* f0-29 f0-29)) + (f1-9 f28-0) + (f1-12 (sqrtf (fabs (- f0-31 (* f1-9 f1-9))))) + (f0-35 (/ (* f28-0 f1-12) f30-0)) + ) + (let ((f1-15 (/ (* f1-12 f1-12) f30-0))) + (set! (-> arg2 quad) (-> arg0 quad)) + (let ((a1-13 arg2)) + (let ((v1-26 arg2)) + (let ((a0-14 (-> s5-0 0))) + (let ((a2-5 f1-15)) + (.mov vf7 a2-5) + ) + (.lvf vf5 (&-> a0-14 quad)) + ) + (.lvf vf4 (&-> v1-26 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-13 quad) vf6) + ) + ) + (let ((a1-14 arg2)) + (let ((v1-27 arg2)) + (let ((a0-15 (-> s5-0 1))) + (let ((a2-6 f0-35)) + (.mov vf7 a2-6) + ) + (.lvf vf5 (&-> a0-15 quad)) + ) + (.lvf vf4 (&-> v1-27 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-14 quad) vf6) + ) + ) + ) + (set! (-> arg2 y) (-> s5-0 2 y)) + ) + arg2 + ) + ) + +(defmethod city-level-info-method-18 city-level-info ((obj city-level-info)) + (local-vars (sv-48 int)) + (let ((gp-0 (new 'stack-no-clear 'bounding-box)) + (s5-0 (-> obj nav-graph)) + ) + (set! sv-48 (-> s5-0 node-count)) + (dotimes (s4-0 sv-48) + (let ((s3-0 (-> s5-0 node-array s4-0))) + (set-id-and-link-branches-back s3-0 (the-as uint s4-0)) + (let ((a1-1 s3-0) + (v1-4 (-> gp-0 min)) + ) + (set! (-> v1-4 quad) (-> a1-1 position quad)) + (set! (-> v1-4 w) 1.0) + ) + (dotimes (s2-0 (-> s3-0 branch-count)) + (let ((s1-0 (-> s3-0 branch-array s2-0))) + (let ((a1-4 (-> s1-0 dest-node)) + (v1-6 (-> gp-0 max)) + ) + (set! (-> v1-6 quad) (-> a1-4 position quad)) + (set! (-> v1-6 w) 1.0) + ) + (set! (-> s1-0 max-user-count) + (the-as uint (max 1 (the int (/ (vector-vector-distance (-> gp-0 min) (-> gp-0 max)) + (if (logtest? (-> s3-0 flags) (nav-node-flag-byte pedestrian)) + 24576.0 + 49152.0 + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; WARN: Return type mismatch object vs symbol. +(defmethod city-level-info-method-9 city-level-info ((obj city-level-info)) + (local-vars + (sv-96 (inline-array nav-node)) + (sv-100 int) + (sv-104 vis-ray) + (sv-112 int) + (sv-160 nav-node) + (sv-164 vector) + (sv-168 vector) + (sv-172 vis-cell) + (sv-176 int) + (sv-184 nav-branch) + (sv-240 nav-node) + (sv-244 vector) + (sv-248 vector) + (sv-252 vector) + (sv-256 nav-segment) + (sv-260 vis-cell) + (sv-264 int) + ) + (set! (-> obj cell-count) + (the-as uint (* (* (-> obj grid-info dimension-array 0) (-> obj grid-info dimension-array 1)) + (-> obj grid-info dimension-array 2) + ) + ) + ) + (let ((s5-0 (-> obj cell-count))) + (dotimes (s4-0 (the-as int s5-0)) + (reset-segment-counts (-> obj cell-array s4-0)) + ) + (when (< 0.01 (-> obj grid-info axis-scale 0)) + (format 0 "segments not generates~%") + (return (the-as symbol #t)) + ) + (set! sv-96 (-> obj nav-graph node-array)) + (set! sv-100 (-> obj nav-graph node-count)) + (set! sv-104 (new 'stack-no-clear 'vis-ray)) + (set! sv-112 0) + (dotimes (s4-1 sv-100) + (let ((s3-0 (-> sv-96 s4-1))) + (dotimes (s2-0 (-> s3-0 branch-count)) + (let* ((a2-0 (-> s3-0 branch-array s2-0)) + (f0-1 0.0) + (v1-19 a2-0) + ) + (when (< f0-1 (* 0.0078125 (the float (-> v1-19 density)))) + (set! sv-160 (-> a2-0 dest-node)) + (set! sv-164 (new 'stack-no-clear 'vector)) + (set! sv-168 (new 'stack-no-clear 'vector)) + (set! sv-172 (the-as vis-cell #f)) + (set! sv-176 0) + (let ((a1-1 s3-0) + (v1-26 sv-168) + ) + (set! (-> v1-26 quad) (-> a1-1 position quad)) + (set! (-> v1-26 w) 1.0) + ) + (cond + ((logtest? (-> s3-0 flags) (nav-node-flag-byte pedestrian)) + (let ((a1-4 (-> a2-0 dest-node)) + (v1-29 sv-164) + ) + (set! (-> v1-29 quad) (-> a1-4 position quad)) + (set! (-> v1-29 w) 1.0) + ) + ) + (else + (city-level-info-method-12 obj sv-168 a2-0 sv-164) + ) + ) + (init-vis-ray obj sv-104 sv-168 sv-164) + (while (< 0.0 (-> sv-104 len)) + (set! sv-172 (-> sv-104 cell)) + (city-level-info-method-11 obj sv-104) + (+! (-> sv-172 segment-count) 1) + (set! sv-112 (+ sv-112 1)) + (if (> sv-176 0) + (+! (-> sv-172 incoming-segment-count) 1) + ) + (set! sv-176 (+ sv-176 1)) + ) + ) + ) + ) + ) + ) + (format 0 "~d segments were generated~%" sv-112) + (set! (-> obj segment-array) (the-as (inline-array nav-segment) (malloc 'debug (* 48 sv-112)))) + (let ((v1-59 0)) + (dotimes (a0-20 (the-as int s5-0)) + (let ((a1-14 (-> obj cell-array a0-20))) + (set! (-> a1-14 id) (the-as uint a0-20)) + (set! (-> a1-14 segment-array) (the-as (inline-array nav-segment) #f)) + (when (> (-> a1-14 segment-count) 0) + (set! (-> a1-14 segment-array) (the-as (inline-array nav-segment) (-> obj segment-array v1-59))) + (dotimes (a2-8 (-> a1-14 segment-count)) + (let ((a3-5 (-> a1-14 segment-array a2-8))) + (set! (-> a3-5 id) (the-as uint v1-59)) + (set! (-> a3-5 cell-id) (the-as uint #xffff)) + ) + (+! v1-59 1) + ) + ) + (set! (-> a1-14 flags) (the-as vis-cell-flag (-> a1-14 segment-count))) + (set! (-> a1-14 segment-count) 0) + (set! (-> a1-14 incoming-segment-count) 0) + ) + 0 + ) + (set! (-> obj segment-count) v1-59) + ) + ) + (dotimes (s5-1 sv-100) + (let ((s4-2 (-> sv-96 s5-1))) + (dotimes (s3-1 (-> s4-2 branch-count)) + (set! sv-184 (-> s4-2 branch-array s3-1)) + (let ((f0-5 0.0) + (v1-63 sv-184) + ) + (when (< f0-5 (* 0.0078125 (the float (-> v1-63 density)))) + (set! sv-240 (-> sv-184 dest-node)) + (set! sv-244 (new 'stack-no-clear 'vector)) + (set! sv-248 (new 'stack-no-clear 'vector)) + (set! sv-252 (new 'stack-no-clear 'vector)) + (set! sv-256 (the-as nav-segment #f)) + (set! sv-260 (the-as vis-cell #f)) + (set! sv-264 0) + (let ((a1-16 s4-2) + (v1-72 sv-244) + ) + (set! (-> v1-72 quad) (-> a1-16 position quad)) + (set! (-> v1-72 w) 1.0) + ) + (cond + ((logtest? (-> s4-2 flags) (nav-node-flag-byte pedestrian)) + (let ((a1-19 (-> sv-184 dest-node)) + (v1-76 sv-252) + ) + (set! (-> v1-76 quad) (-> a1-19 position quad)) + (set! (-> v1-76 w) 1.0) + ) + ) + (else + (city-level-info-method-12 obj sv-244 sv-184 sv-252) + ) + ) + (init-vis-ray obj sv-104 sv-244 sv-252) + (while (< 0.0 (-> sv-104 len)) + (set! (-> sv-248 quad) (-> sv-104 pos quad)) + (set! sv-260 (-> sv-104 cell)) + (city-level-info-method-11 obj sv-104) + (let ((a2-14 (-> sv-260 incoming-segment-count))) + (if (zero? sv-264) + (set! a2-14 + (+ (- -1 (-> sv-260 segment-count)) (-> sv-260 incoming-segment-count) (-> sv-260 alloc-segment-count)) + ) + ) + (when (or (< a2-14 0) (>= a2-14 (-> sv-260 alloc-segment-count))) + (format + 0 + "******************************************************** bad i-seg ~d ************************************************~%" + a2-14 + ) + (return (the-as symbol #f)) + ) + (let ((s2-1 (-> sv-260 segment-array a2-14))) + (set! (-> s2-1 vertex 0 quad) (-> sv-248 quad)) + (set! (-> s2-1 vertex 1 quad) (-> sv-104 pos quad)) + (set! (-> s2-1 length) (vector-vector-distance (the-as vector (-> s2-1 vertex)) (-> s2-1 vertex 1))) + (let* ((f0-9 (if (logtest? (-> s4-2 flags) (nav-node-flag-byte pedestrian)) + 24576.0 + 49152.0 + ) + ) + (f1-8 -1.0) + (f2-4 0.0001) + (v1-107 sv-184) + (f2-5 (fmax f2-4 (* 0.0078125 (the float (-> v1-107 density))))) + ) + (set! (-> s2-1 spawn-spacing) (* f0-9 (+ f1-8 (/ 1.0 f2-5)))) + ) + (set! (-> s2-1 cell-id) (-> sv-260 id)) + (set! (-> s2-1 branch) sv-184) + (set! (-> s2-1 from-cell-id) (the-as uint #xffff)) + (set! (-> s2-1 nav-mesh-id) (-> s4-2 nav-mesh-id)) + (set! (-> s2-1 tracker-id) 0) + (if (logtest? (-> s4-2 flags) (nav-node-flag-byte pedestrian)) + (set! (-> s2-1 tracker-id) 1) + ) + (if sv-256 + (set! (-> s2-1 from-cell-id) (-> (the-as nav-segment sv-256) cell-id)) + ) + (set! sv-256 s2-1) + ) + ) + 0 + (+! (-> sv-260 segment-count) 1) + (if (> sv-264 0) + (+! (-> sv-260 incoming-segment-count) 1) + ) + (set! sv-264 (+ sv-264 1)) + ) + ) + ) + ) + ) + ) + (the-as symbol 0) + ) + +(defmethod debug-check-proc-in-tracker traffic-engine ((obj traffic-engine) (arg0 process) (arg1 int)) + (let ((v1-3 (-> obj tracker-array arg1)) + (a0-3 (process->handle arg0)) + (a3-4 0) + ) + (b! #t cfg-8 :delay (nop!)) + (label cfg-6) + (b! (= (-> v1-3 active-object-list a3-4) a0-3) cfg-10 :delay (nop!)) + (+! a3-4 1) + (label cfg-8) + (b! (< a3-4 (the-as int (-> v1-3 active-object-count))) cfg-6) + ) + (format #t "proc pid ~d (~a) not found in tracker ~d~%" (-> arg0 pid) arg0 arg1) + (label cfg-10) + 0 + 0 + (none) + ) diff --git a/goal_src/jak2/levels/city/common/traffic-manager.gc b/goal_src/jak2/levels/city/common/traffic-manager.gc index 7cc377a254..74358f7b6c 100644 --- a/goal_src/jak2/levels/city/common/traffic-manager.gc +++ b/goal_src/jak2/levels/city/common/traffic-manager.gc @@ -6,3 +6,863 @@ ;; dgos: CWI ;; DECOMP BEGINS + +(define *traffic-engine* (the-as traffic-engine #f)) + +(define *traffic-fast-spawn* #f) + +(deftype traffic-manager (process) + ((traffic-engine traffic-engine :offset-assert 128) + (fast-spawn basic :offset-assert 132) + (dark-guard-ratio int32 :offset-assert 136) + (spawn-params traffic-object-spawn-params :inline :offset-assert 144) + ) + :heap-base #x80 + :method-count-assert 22 + :size-assert #xf8 + :flag-assert #x16008000f8 + (:methods + (idle () _type_ :state 14) + (active () _type_ :state 15) + (traffic-manager-method-16 (_type_) none 16) + (spawn-all (_type_) none 17) + (traffic-manager-method-18 (_type_) none 18) + (kill-all (_type_) none 19) + (traffic-manager-method-20 (_type_) none 20) + (traffic-manager-method-21 (_type_) none 21) + ) + ) + + +(defun draw-city-info ((arg0 city-level-info) (arg1 vis-grid-pos)) + "@unused - but would be cool to revive! TODO" + (let ((v1-0 (-> arg0 grid-info box))) + (add-debug-box #t (bucket-id debug2) (-> v1-0 min) (-> v1-0 max) *color-yellow*) + ) + (debug-draw-grid (-> arg0 grid-info) *color-gray*) + (debug-draw-cell (-> arg0 grid-info) arg1 *color-red*) + (let* ((v1-8 (+ (-> arg1 x) + (* (-> arg1 z) (-> arg0 grid-info dimension-array 0)) + (* (* (-> arg1 y) (-> arg0 grid-info dimension-array 0)) (-> arg0 grid-info dimension-array 2)) + ) + ) + (v1-10 (-> arg0 cell-array v1-8)) + ) + (add-debug-sphere #t (bucket-id debug2) (-> v1-10 sphere) (-> v1-10 sphere r) *color-green*) + ) + 0 + (none) + ) + +(defmethod traffic-manager-method-16 traffic-manager ((obj traffic-manager)) + (update-traffic (-> obj traffic-engine)) + (traffic-manager-method-18 obj) + (spawn-all obj) + (if *debug-segment* + (debug-unused (-> obj traffic-engine)) + ) + (if *display-traffic-height-map* + (debug-draw *traffic-height-map* (target-pos 0)) + ) + (when *display-trail-graph* + (let ((a0-7 *trail-graph*)) + (if a0-7 + (debug-draw a0-7) + ) + ) + ) + 0 + (none) + ) + +(defmethod traffic-manager-method-18 traffic-manager ((obj traffic-manager)) + (let ((s5-0 0)) + (while (< (the-as uint s5-0) (the-as uint 21)) + (let ((v1-2 (-> obj traffic-engine object-type-info-array s5-0))) + (when (logtest? (-> v1-2 flags) 2) + (let ((a0-5 (+ (-> v1-2 active-count) (-> v1-2 inactive-count)))) + (when (< (-> v1-2 want-count) a0-5) + (let ((a0-10 (handle->process (get-from-inactive-by-type + (-> obj traffic-engine tracker-array (-> v1-2 tracker-index)) + (the-as traffic-type s5-0) + ) + ) + ) + ) + (if a0-10 + (deactivate a0-10) + ) + ) + ) + ) + ) + ) + (+! s5-0 1) + ) + ) + 0 + (none) + ) + +(defmethod kill-all traffic-manager ((obj traffic-manager)) + (let ((s5-0 0)) + (while (< (the-as uint s5-0) (the-as uint 21)) + (let ((s4-0 (-> obj traffic-engine object-type-info-array s5-0))) + (countdown (s3-0 (-> s4-0 inactive-count)) + (let ((a0-6 (handle->process (get-from-inactive-by-type + (-> obj traffic-engine tracker-array (-> s4-0 tracker-index)) + (the-as traffic-type s5-0) + ) + ) + ) + ) + (if a0-6 + (deactivate a0-6) + ) + ) + ) + ) + (+! s5-0 1) + ) + ) + 0 + (none) + ) + +(defmethod spawn-all traffic-manager ((obj traffic-manager)) + (let ((s5-0 0)) + (b! #t cfg-4 :delay (nop!)) + (label cfg-1) + (let ((s4-0 (-> obj traffic-engine object-type-info-array s5-0))) + (set! (-> s4-0 flags) (logand -9 (-> s4-0 flags))) + (if (= (level-status *level* (the-as symbol (-> s4-0 level))) 'active) + (logior! (-> s4-0 flags) 8) + ) + ) + (+! s5-0 1) + (label cfg-4) + (b! (< s5-0 21) cfg-1) + ) + (let ((s5-1 1) + (s4-1 0) + (s3-1 #x1fffff) + ) + (if (-> obj fast-spawn) + (set! s5-1 120) + ) + (b! #t cfg-36 :delay (nop!)) + (label cfg-8) + (let* ((s2-0 (-> obj spawn-params)) + (s1-0 (-> s2-0 object-type)) + ) + (when (logtest? s3-1 (ash 1 s1-0)) + (let ((s0-0 (-> obj traffic-engine object-type-info-array s1-0))) + (let ((v1-21 (+ (-> s0-0 active-count) (-> s0-0 inactive-count)))) + (b! + (not (and (logtest? (-> s0-0 flags) 2) (logtest? (-> s0-0 flags) 8) (< v1-21 (-> s0-0 want-count)))) + cfg-29 + :delay (nop!) + ) + (set! (-> s2-0 flags) (logand -9 (-> s2-0 flags))) + (b! + (not (and (= (-> s2-0 object-type) (traffic-type crimson-guard-1)) + (> (-> obj dark-guard-ratio) 0) + (zero? (mod v1-21 (-> obj dark-guard-ratio))) + ) + ) + cfg-25 + :delay (empty-form) + ) + ) + (logior! (-> s2-0 flags) 8) + (label cfg-25) + (let ((a2-0 (traffic-object-spawn obj s2-0))) + (b! (not a2-0) cfg-27 :delay (nop!)) + (add-object (-> obj traffic-engine) s1-0 a2-0) + ) + (+! (-> s0-0 reserve-count) -1) + ) + (+! (-> s2-0 id) 1) + (+! s4-1 1) + (b! #t cfg-28 :delay (nop!)) + (label cfg-27) + (format 0 "traffic-manager: unable to spawn~%") + (b! #t cfg-41 :delay (nop!)) + (label cfg-28) + (b! #t cfg-33 :delay (nop!)) + (label cfg-29) + (set! s3-1 (logclear s3-1 (ash 1 s1-0))) + ) + (label cfg-33) + (let ((v1-37 (the-as int (+ s1-0 1)))) + (if (>= (the-as uint v1-37) (the-as uint 21)) + (set! v1-37 0) + ) + (set! (-> s2-0 object-type) (the-as traffic-type v1-37)) + ) + ) + (label cfg-36) + (b! (and (< s4-1 s5-1) (nonzero? s3-1)) cfg-8 :delay (nop!)) + ) + (label cfg-41) + (set! (-> obj fast-spawn) #f) + 0 + 0 + (none) + ) + +;; WARN: Return type mismatch process vs process-drawable. +(defun vehicle-spawn ((arg0 process) (arg1 type) (arg2 traffic-object-spawn-params)) + (let ((gp-0 (the-as process #f))) + (let* ((s3-0 (get-process *default-dead-pool* arg1 #x4000)) + (v1-1 (when s3-0 + (let ((t9-1 (method-of-type process activate))) + (t9-1 s3-0 arg0 (symbol->string (-> arg1 symbol)) (the-as pointer #x70004000)) + ) + (run-now-in-process s3-0 vehicle-init-by-other arg2) + (-> s3-0 ppointer) + ) + ) + ) + (if v1-1 + (set! gp-0 (-> v1-1 0)) + ) + ) + (if (and gp-0 (logtest? (-> arg2 flags) 2)) + (vehicle-method-137 (the-as vehicle gp-0) arg2) + ) + (the-as process-drawable gp-0) + ) + ) + +;; WARN: Return type mismatch process vs process-drawable. +(defun citizen-spawn ((arg0 process) (arg1 type) (arg2 traffic-object-spawn-params)) + ;; added check + (when (zero? citizen-init-by-other) + (return (the process-drawable #f)) + ) + (let ((gp-0 (the-as process #f))) + (let* ((s3-0 (get-process *default-dead-pool* arg1 #x4000)) + (v1-1 (when s3-0 + (let ((t9-1 (method-of-type process activate))) + (t9-1 s3-0 arg0 (symbol->string (-> arg1 symbol)) (the-as pointer #x70004000)) + ) + (run-now-in-process s3-0 citizen-init-by-other arg2) + (-> s3-0 ppointer) + ) + ) + ) + (if v1-1 + (set! gp-0 (-> v1-1 0)) + ) + ) + (the-as process-drawable gp-0) + ) + ) + +(defun traffic-object-spawn ((arg0 process) (arg1 traffic-object-spawn-params)) + (let ((v0-0 (the-as process-drawable #f))) + (case (-> arg1 object-type) + (((traffic-type bikea)) + (set! v0-0 (vehicle-spawn arg0 bikea arg1)) + ) + (((traffic-type bikeb)) + (set! v0-0 (vehicle-spawn arg0 bikeb arg1)) + ) + (((traffic-type bikec)) + (set! v0-0 (vehicle-spawn arg0 bikec arg1)) + ) + (((traffic-type cara)) + (set! v0-0 (vehicle-spawn arg0 cara arg1)) + ) + (((traffic-type carb)) + (set! v0-0 (vehicle-spawn arg0 carb arg1)) + ) + (((traffic-type carc)) + (set! v0-0 (vehicle-spawn arg0 carc arg1)) + ) + (((traffic-type guard-bike)) + (set! v0-0 (vehicle-spawn arg0 guard-bike arg1)) + ) + (((traffic-type hellcat)) + (set! v0-0 (vehicle-spawn arg0 hellcat arg1)) + ) + (((traffic-type citizen-norm-1)) + (set! v0-0 (citizen-spawn arg0 citizen-norm arg1)) + ) + (((traffic-type citizen-chick)) + (set! v0-0 (citizen-spawn arg0 citizen-chick arg1)) + ) + (((traffic-type citizen-fat)) + (set! v0-0 (citizen-spawn arg0 citizen-fat arg1)) + ) + (((traffic-type citizen-norm-2)) + (set! v0-0 (citizen-spawn arg0 citizen-norm arg1)) + ) + (((traffic-type metalhead-predator)) + (set! v0-0 (citizen-spawn arg0 metalhead-predator arg1)) + ) + (((traffic-type metalhead-grunt)) + (set! v0-0 (citizen-spawn arg0 metalhead-grunt arg1)) + ) + (((traffic-type metalhead-flitter)) + (set! v0-0 (citizen-spawn arg0 metalhead-flitter arg1)) + ) + (((traffic-type crimson-guard-1)) + (set! v0-0 (citizen-spawn arg0 crimson-guard arg1)) + ) + (((traffic-type crimson-guard-0)) + (set! v0-0 (citizen-spawn arg0 crimson-guard arg1)) + ) + ) + v0-0 + ) + ) + +(defun type-from-vehicle-type ((arg0 vehicle-type)) + (case arg0 + (((vehicle-type bikea)) + bikea + ) + (((vehicle-type bikeb)) + bikeb + ) + (((vehicle-type bikec)) + bikec + ) + (((vehicle-type cara)) + cara + ) + (((vehicle-type carb)) + carb + ) + (((vehicle-type carc)) + carc + ) + (((vehicle-type guard-bike)) + guard-bike + ) + (((vehicle-type hellcat)) + hellcat + ) + (((vehicle-type evan-test-bike)) + evan-test-bike + ) + (((vehicle-type test-bike)) + test-bike + ) + (((vehicle-type test-car)) + test-car + ) + (else + bikea + ) + ) + ) + +(defmethod traffic-manager-method-20 traffic-manager ((obj traffic-manager)) + (set! (-> obj traffic-engine) *traffic-engine*) + (reset-and-init-from-manager (-> obj traffic-engine) obj) + (restore-city-speeches) + 0 + (none) + ) + +;; WARN: Return type mismatch process vs traffic-manager. +(defmethod relocate traffic-manager ((obj traffic-manager) (arg0 int)) + (set! *traffic-manager* obj) + (if *traffic-manager* + (set! *traffic-manager* (&+ *traffic-manager* arg0)) + ) + (the-as traffic-manager ((method-of-type process relocate) obj arg0)) + ) + +(defmethod deactivate traffic-manager ((obj traffic-manager)) + (stop-alarm-sound (-> obj traffic-engine)) + (set! *traffic-manager* #f) + (remove-setting *setting-control* obj 'task-mask) + (apply-settings *setting-control*) + (speech-control-method-9 *speech-control*) + ((method-of-type process deactivate) obj) + (none) + ) + +(defmethod traffic-manager-method-21 traffic-manager ((obj traffic-manager)) + (let ((s5-0 (new 'stack-no-clear 'array 'int8 21))) + (set! (-> s5-0 11) 8) + (set! (-> s5-0 12) 8) + (set! (-> s5-0 13) 8) + (set! (-> s5-0 14) 7) + (set! (-> s5-0 15) 7) + (set! (-> s5-0 16) 7) + (set! (-> s5-0 18) 4) + (set! (-> s5-0 19) 3) + (set! (-> s5-0 20) 0) + (set! (-> s5-0 0) 15) + (set! (-> s5-0 1) 15) + (set! (-> s5-0 2) 14) + (set! (-> s5-0 3) 1) + (set! (-> s5-0 4) 1) + (set! (-> s5-0 6) 9) + (set! (-> s5-0 7) 0) + (set! (-> s5-0 8) 14) + (set! (-> s5-0 9) 14) + (set! (-> s5-0 10) 14) + (set! (-> obj fast-spawn) (the-as basic *traffic-fast-spawn*)) + (traffic-manager-method-20 obj) + (let ((v1-20 (-> obj traffic-engine))) + (dotimes (a0-2 21) + (set! (-> v1-20 object-type-info-array a0-2 want-count) (-> s5-0 a0-2)) + ) + ) + ) + (let ((s5-1 (-> obj spawn-params))) + (set! (-> s5-1 object-type) (traffic-type crimson-guard-1)) + (set! (-> s5-1 behavior) (the-as uint 1)) + (set! (-> s5-1 id) (the-as uint 0)) + (set! (-> s5-1 nav-mesh) #f) + (set! (-> s5-1 nav-branch) #f) + (set! (-> s5-1 proc) #f) + (set! (-> s5-1 handle) (the-as uint #f)) + (set! (-> s5-1 user-data) (the-as uint 0)) + (set! (-> s5-1 flags) (the-as uint 2)) + (set! (-> s5-1 guard-type) (the-as uint 7)) + (vector-reset! (-> s5-1 velocity)) + (vector-reset! (-> s5-1 position)) + (forward-up-nopitch->quaternion + (-> s5-1 rotation) + (new 'static 'vector :z 1.0 :w 1.0) + (new 'static 'vector :y 1.0 :w 1.0) + ) + (set! (-> s5-1 id) (the-as uint 1)) + ) + (set! (-> obj dark-guard-ratio) (if (task-node-closed? (game-task-node tomb-boss-resolution)) + 5 + 0 + ) + ) + (restore-default-settings (-> obj traffic-engine)) + (set! *traffic-manager* obj) + 0 + (none) + ) + +(defbehavior traffic-manager-event-handler traffic-manager ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (let ((gp-0 (the-as object #t))) + (case arg2 + (('child-killed) + (child-killed (-> self traffic-engine) arg0) + ) + (('increase-alert-level) + (when *target* + (let ((a1-4 (-> arg3 param 0))) + (increase-alert-level (-> self traffic-engine) (the-as int a1-4) *target*) + ) + ) + ) + (('decrease-alert-level) + (let ((a1-5 (-> arg3 param 0))) + (decrease-alert-level (-> self traffic-engine) (the-as int a1-5)) + ) + ) + (('set-alert-level) + (let ((a1-6 (-> arg3 param 0))) + (set-alert-level (-> self traffic-engine) (the-as int a1-6)) + ) + ) + (('set-max-alert-level) + (let ((a1-7 (-> arg3 param 0))) + (set-max-alert-level (-> self traffic-engine) (the-as int a1-7)) + ) + ) + (('get-alert-level) + (set! gp-0 (get-alert-level (-> self traffic-engine))) + ) + (('set-alert-duration) + (let ((a1-8 (-> arg3 param 0))) + (set-alert-duration (-> self traffic-engine) (the-as int a1-8)) + ) + ) + (('deactivate-all) + (deactivate-all (-> self traffic-engine)) + ) + (('set-target-level) + (let ((f0-0 (the-as float (-> arg3 param 0)))) + (set-target-level (-> self traffic-engine) f0-0) + ) + ) + (('set-guard-target-level) + (let ((f0-1 (the-as float (-> arg3 param 0)))) + (set-guard-target-level (-> self traffic-engine) f0-1) + ) + ) + (('restore-default-settings) + (restore-default-settings (-> self traffic-engine)) + ) + (('add-danger-sphere) + (let ((a1-11 (-> arg3 param 0))) + (add-danger (-> self traffic-engine) (the-as traffic-danger-info a1-11)) + ) + ) + (('spawn-object) + (let ((s5-0 (the-as traffic-object-spawn-params (-> arg3 param 0)))) + (set! (-> s5-0 proc) (traffic-object-spawn self s5-0)) + ) + ) + (('activate-object) + (let ((a1-13 (-> arg3 param 0))) + (activate-object (-> self traffic-engine) (the-as traffic-object-spawn-params a1-13)) + ) + ) + (('get-object-remaining-count) + (let ((a1-14 (-> arg3 param 0))) + (set! gp-0 (get-object-remaining-count (-> self traffic-engine) (the-as int a1-14))) + ) + ) + (('set-object-reserve-count) + (let ((a1-15 (-> arg3 param 0)) + (a2-2 (-> arg3 param 1)) + ) + (set-object-reserve-count (-> self traffic-engine) (the-as int a1-15) a2-2) + ) + ) + (('get-object-reserve-count) + (let ((a1-16 (-> arg3 param 0))) + (set! gp-0 (get-object-reserve-count (-> self traffic-engine) (the-as int a1-16))) + ) + ) + (('set-object-target-level) + (let ((a1-17 (-> arg3 param 0)) + (f0-2 (the-as float (-> arg3 param 1))) + ) + (set-object-target-level (-> self traffic-engine) (the-as int a1-17) f0-2) + ) + ) + (('set-object-target-count) + (let ((a1-18 (-> arg3 param 0)) + (a2-4 (-> arg3 param 1)) + ) + (set-object-target-count (-> self traffic-engine) (the-as int a1-18) (the-as int a2-4)) + ) + ) + (('set-guard-target-count-range) + (let ((a1-19 (-> arg3 param 0)) + (a2-5 (-> arg3 param 1)) + (a3-1 (-> arg3 param 2)) + ) + (set-guard-target-count-range (-> self traffic-engine) (the-as int a1-19) (the-as int a2-5) (the-as int a3-1)) + ) + ) + (('deactivate-by-type) + (let ((a1-20 (-> arg3 param 0))) + (deactivate-by-type (-> self traffic-engine) (the-as traffic-type a1-20)) + ) + ) + (('new-suppression-box) + (let ((a1-21 (-> arg3 param 0))) + (new-suppression-box (-> self traffic-engine) (the-as traffic-suppression-params a1-21)) + ) + ) + (('update-suppression-box) + (let ((a1-22 (-> arg3 param 0))) + (update-suppression-box (-> self traffic-engine) (the-as traffic-suppression-params a1-22)) + ) + ) + (('kill-traffic-sphere) + (let ((a1-23 (-> arg3 param 0))) + (kill-traffic-sphere (-> self traffic-engine) (the-as sphere a1-23)) + ) + ) + (('set-guard-multi-focus) + (let ((a0-74 (-> arg3 param 0)) + (v1-29 (-> self traffic-engine alert-state)) + ) + (if a0-74 + (logior! (-> v1-29 flags) (traffic-alert-flag guard-multi-focus)) + (logclear! (-> v1-29 flags) (traffic-alert-flag guard-multi-focus)) + ) + ) + ) + (('set-disable-pursuit-control) + (let ((a0-80 (-> arg3 param 0)) + (v1-31 (-> self traffic-engine alert-state)) + ) + (if a0-80 + (logior! (-> v1-31 flags) (traffic-alert-flag disable-pursuit-control)) + (logclear! (-> v1-31 flags) (traffic-alert-flag disable-pursuit-control)) + ) + ) + ) + (('set-object-auto-activate) + (let ((a1-26 (-> arg3 param 0)) + (a2-6 (-> arg3 param 1)) + ) + (set-object-auto-activate (-> self traffic-engine) (the-as int a1-26) a2-6) + ) + ) + (('set-guard-force-visible) + (let ((a0-89 (-> arg3 param 0)) + (v1-34 (-> self traffic-engine alert-state target-status-array)) + ) + (if a0-89 + (logior! (-> v1-34 0 flags) (traffic-target-flag force-visible)) + (logclear! (-> v1-34 0 flags) (traffic-target-flag force-visible)) + ) + ) + ) + (('end-pursuit-by-type) + (let ((a1-28 (-> arg3 param 0))) + (end-pursuit-by-type (-> self traffic-engine) (the-as traffic-type a1-28)) + ) + ) + (('level-loaded) + (let ((a1-29 (-> arg3 param 0))) + (level-loaded (-> self traffic-engine) (the-as level a1-29)) + ) + ) + (('level-killed) + (let ((s5-1 (the-as object (-> arg3 param 0)))) + (level-killed (-> self traffic-engine) (the-as level s5-1)) + (format #t "traffic-manager : level killed ~S~%" (-> (the-as level s5-1) nickname)) + ) + ) + (('add-object) + (let ((a1-32 (-> arg3 param 0)) + (a2-8 (-> arg3 param 1)) + ) + (add-object (-> self traffic-engine) (the-as traffic-type a1-32) (the-as process a2-8)) + ) + ) + (('kill-all) + (format #t "traffic-manager::kill-all~%") + (deactivate-all (-> self traffic-engine)) + (kill-all self) + ) + (('spawn-all) + (format #t "traffic-manager::spawn-all~%") + (set! (-> self fast-spawn) (the-as basic #t)) + (spawn-all self) + ) + (('set-density-factor) + (let ((f0-3 (the-as float (-> arg3 param 0)))) + (set! (-> self traffic-engine inv-density-factor) (/ 5.0 f0-3)) + ) + ) + (('rider-off) + (let ((s5-2 (-> self child))) + (while s5-2 + (send-event (ppointer->process s5-2) 'rider-off) + (set! s5-2 (-> s5-2 0 brother)) + ) + ) + ) + (('rider-on) + (let ((s5-3 (-> self child))) + (while s5-3 + (send-event (ppointer->process s5-3) 'rider-on) + (set! s5-3 (-> s5-3 0 brother)) + ) + ) + ) + (else + (set! gp-0 #f) + ) + ) + gp-0 + ) + ) + +;; WARN: Return type mismatch object vs none. +(defbehavior traffic-manager-init-by-other traffic-manager () + (stack-size-set! (-> self main-thread) 128) + (ctywide-entity-hack) + (traffic-manager-method-21 self) + (add-setting! 'task-mask 'clear 0 #x4000) + (set! (-> self event-hook) traffic-manager-event-handler) + (rigid-body-queue-manager-spawn *traffic-rigid-body-queue* self) + (go-virtual idle) + (none) + ) + +(defun traffic-start () + (kill-by-type traffic-manager *active-pool*) + (process-spawn traffic-manager :from *city-dead-pool* :to *entity-pool*) + 0 + (none) + ) + +;; WARN: Return type mismatch symbol vs none. +(defun traffic-kill () + (kill-by-type traffic-manager *active-pool*) + (none) + ) + +(defstate idle (traffic-manager) + :virtual #t + :event traffic-manager-event-handler + :enter (behavior () + (spawn-all self) + (none) + ) + :code (behavior () + (suspend) + (suspend) + (go-virtual active) + (none) + ) + ) + +(defstate active (traffic-manager) + :virtual #t + :event traffic-manager-event-handler + :code (the-as (function none :behavior traffic-manager) sleep-code) + :post (behavior () + (traffic-manager-method-16 self) + (none) + ) + ) + +;; WARN: Return type mismatch object vs none. +(defun riders-on () + (send-event *traffic-manager* 'rider-on) + (none) + ) + +;; WARN: Return type mismatch object vs none. +(defun riders-off () + (send-event *traffic-manager* 'rider-off) + (none) + ) + +(defun ctywide-login () + (format 0 "citywide-login~%") + (set! *traffic-engine* (new 'loading-level 'traffic-engine)) + (init *city-dead-pool* 'loading-level #x8000) + 0 + (none) + ) + +(defun ctywide-activate ((arg0 level) (arg1 symbol)) + (when (zero? (-> arg0 entity length)) + (format 0 "ERROR: ctywide-activate: level ~s has no entities!!" (-> arg0 name)) + (break!) + 0 + ) + (set! *ctywide-entity* (-> arg0 entity data 0 entity)) + (set! *traffic-fast-spawn* (or (= arg1 'life) (= arg1 'debug))) + (if (and (= arg1 'debug) (not *spawn-actors*)) + (traffic-kill) + (traffic-start) + ) + 0 + (none) + ) + +(define *traffic-alert-level-force* #f) + +(defun lwide-activate ((arg0 level) (arg1 symbol)) + (format #t "lwide-activate~%") + (set! *lwide-entity* (-> arg0 entity data 0 entity)) + (let ((gp-0 *traffic-engine*)) + (when gp-0 + (case (-> arg0 name) + (('lwidea) + (set! (-> gp-0 object-type-info-array 0 level) (the-as level 'lwidea)) + (set! (-> gp-0 object-type-info-array 1 level) (the-as level 'lwidea)) + (set! (-> gp-0 object-type-info-array 2 level) (the-as level 'lwidea)) + (set! (-> gp-0 object-type-info-array 3 level) (the-as level 'lwidea)) + (set! (-> gp-0 object-type-info-array 4 level) (the-as level 'lwidea)) + (set! (-> gp-0 object-type-info-array 5 level) #f) + (set! (-> gp-0 object-type-info-array 6 level) (the-as level 'lwidea)) + (set! (-> gp-0 object-type-info-array 7 level) #f) + (set! (-> gp-0 object-type-info-array 8 level) #f) + (set! (-> gp-0 object-type-info-array 9 level) #f) + (set! (-> gp-0 object-type-info-array 10 level) #f) + (set! (-> gp-0 object-type-info-array 11 level) (the-as level 'lwidea)) + (set! (-> gp-0 object-type-info-array 12 level) (the-as level 'lwidea)) + (set! (-> gp-0 object-type-info-array 13 level) (the-as level 'lwidea)) + (set! (-> gp-0 object-type-info-array 14 level) (the-as level 'lwidea)) + (set! (-> gp-0 object-type-info-array 15 level) (the-as level 'lwidea)) + (set! (-> gp-0 object-type-info-array 16 level) (the-as level 'lwidea)) + (set! (-> gp-0 object-type-info-array 17 level) #f) + (set! (-> gp-0 object-type-info-array 18 level) (the-as level 'lwidea)) + (set! (-> gp-0 object-type-info-array 19 level) (the-as level 'lwidea)) + (logior! (-> gp-0 alert-state flags) (traffic-alert-flag target-jak)) + (set! *traffic-alert-level-force* #f) + ) + (('lwideb) + (set! (-> gp-0 object-type-info-array 0 level) (the-as level 'lwideb)) + (set! (-> gp-0 object-type-info-array 1 level) #f) + (set! (-> gp-0 object-type-info-array 2 level) #f) + (set! (-> gp-0 object-type-info-array 3 level) (the-as level 'lwideb)) + (set! (-> gp-0 object-type-info-array 4 level) (the-as level 'lwideb)) + (set! (-> gp-0 object-type-info-array 5 level) #f) + (set! (-> gp-0 object-type-info-array 6 level) (the-as level 'lwideb)) + (set! (-> gp-0 object-type-info-array 7 level) #f) + (set! (-> gp-0 object-type-info-array 8 level) (the-as level 'lwideb)) + (set! (-> gp-0 object-type-info-array 9 level) (the-as level 'lwideb)) + (set! (-> gp-0 object-type-info-array 10 level) (the-as level 'lwideb)) + (set! (-> gp-0 object-type-info-array 11 level) (the-as level 'lwideb)) + (set! (-> gp-0 object-type-info-array 12 level) #f) + (set! (-> gp-0 object-type-info-array 13 level) #f) + (set! (-> gp-0 object-type-info-array 14 level) (the-as level 'lwideb)) + (set! (-> gp-0 object-type-info-array 15 level) #f) + (set! (-> gp-0 object-type-info-array 16 level) #f) + (set! (-> gp-0 object-type-info-array 17 level) #f) + (set! (-> gp-0 object-type-info-array 18 level) (the-as level 'lwideb)) + (set! (-> gp-0 object-type-info-array 19 level) #f) + (logclear! (-> gp-0 alert-state flags) (traffic-alert-flag target-jak)) + (set-alert-level gp-0 3) + (logior! (-> gp-0 alert-state flags) (traffic-alert-flag guard-multi-focus)) + (set-alert-duration gp-0 #x6c258c00) + (set! *traffic-alert-level-force* #t) + ) + ) + ) + ) + 0 + (none) + ) + +(defun lwide-deactivate () + (set! *lwide-entity* (the-as object #f)) + (send-event *traffic-manager* 'kill-all) + 0 + (none) + ) + +(defun ctywide-deactivate () + (set! *ctywide-entity* (the-as object #f)) + (set! *traffic-engine* #f) + (set! *trail-graph* #f) + (init *city-dead-pool* 'loading-level 0) + 0 + (none) + ) + +(defun ctywide-entity-hack () + (with-pp + (cond + ((and (-> pp entity) (= pp (-> pp entity extra process))) + (let ((v1-6 (level-get *level* 'ctywide))) + (if v1-6 + (set! (-> pp level) v1-6) + ) + ) + ) + (else + (process-entity-set! pp (the-as entity-actor *ctywide-entity*)) + ) + ) + 0 + (none) + ) + ) + +(defun lwide-entity-hack () + (with-pp + (process-entity-set! pp (the-as entity-actor *lwide-entity*)) + 0 + (none) + ) + ) diff --git a/goal_src/jak2/levels/city/common/transport.gc b/goal_src/jak2/levels/city/common/transport.gc index 6bd17f2877..208818d94c 100644 --- a/goal_src/jak2/levels/city/common/transport.gc +++ b/goal_src/jak2/levels/city/common/transport.gc @@ -70,7 +70,7 @@ (defstate idle (vehicle-turret) :virtual #t :trans (behavior () - (turret-control-method-12 (-> self turret) (the-as joint-mod-rotate-local (-> self turret-jm))) + (update-joint-mod (-> self turret) (the-as joint-mod-rotate-local (-> self turret-jm))) (vehicle-turret-method-29 self) (when (and (nonzero? (-> self target)) (handle->process (-> self target))) (let* ((s5-0 (handle->process (-> self target))) @@ -145,7 +145,7 @@ ;; WARN: Return type mismatch object vs none. (defbehavior vehicle-turret-init-by-other vehicle-turret ((arg0 turret-control-info)) (vehicle-turret-method-28 self) - (turret-control-method-15 (-> self turret) arg0) + (set-info (-> self turret) arg0) (logior! (-> self turret flags) (turret-flag targetting-laser no-rot-y-clamp)) (vehicle-turret-method-29 self) (vector-identity! (-> self root-override scale)) @@ -434,7 +434,7 @@ (with-pp (when (>= (- (-> pp clock frame-counter) (-> obj last-guard-spawn-time)) 0) (let ((s5-0 (new 'stack 'traffic-object-spawn-params))) - (set! (-> s5-0 object-type) (the-as uint 6)) + (set! (-> s5-0 object-type) (traffic-type crimson-guard-1)) (set! (-> s5-0 behavior) (the-as uint 6)) (set! (-> s5-0 id) (the-as uint 0)) (set! (-> s5-0 nav-mesh) (-> obj nav-mesh)) diff --git a/goal_src/jak2/levels/city/common/vehicle-effects.gc b/goal_src/jak2/levels/city/common/vehicle-effects.gc index bb95523fe1..2fc7473656 100644 --- a/goal_src/jak2/levels/city/common/vehicle-effects.gc +++ b/goal_src/jak2/levels/city/common/vehicle-effects.gc @@ -7,7 +7,7 @@ ;; DECOMP BEGINS -(defmethod rigid-body-object-method-36 vehicle ((obj vehicle)) +(defmethod do-engine-sounds vehicle ((obj vehicle)) (local-vars (v1-36 float)) (with-pp (rlet ((acc :class vf) @@ -221,7 +221,7 @@ ) ) -(defmethod vehicle-method-84 vehicle ((obj vehicle) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) +(defmethod draw-thruster vehicle ((obj vehicle) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) (rlet ((acc :class vf) (vf0 :class vf) (vf4 :class vf) @@ -269,7 +269,10 @@ (set! (-> s3-1 1 normal w) f0-14) (set! (-> s3-1 1 normal x) (* 0.025 f0-14)) ) - (add! *simple-sprite-system* (the-as dma-buffer (-> s3-1 1))) + (when (nonzero? *simple-sprite-system*) + ;; added nonzero check + (add! *simple-sprite-system* (the-as dma-buffer (-> s3-1 1))) + ) (forward-up->quaternion (the-as quaternion (-> s3-1 0)) arg1 (the-as vector (-> obj rbody state matrix))) (quaternion-rotate-local-x! (the-as quaternion (-> s3-1 0)) (the-as quaternion (-> s3-1 0)) 32768.0) (let ((v1-16 (-> s3-1 0 normal))) @@ -310,7 +313,7 @@ ) ) -(defmethod vehicle-method-85 vehicle ((obj vehicle)) +(defmethod draw-thrusters vehicle ((obj vehicle)) (local-vars (sv-272 sparticle-launcher) (sv-276 sparticle-launcher)) (with-pp (when (= (-> obj controller traffic sync-mask-32) (ash 1 (logand (-> obj traffic-priority-id) 31))) @@ -433,7 +436,7 @@ ) (dotimes (s4-2 2) (vector-matrix*! (the-as vector (-> s5-0 0)) (-> obj info-override thruster-local-pos s4-2) (-> s5-0 1)) - (vehicle-method-84 obj (the-as vector (-> s5-0 0)) (-> s5-0 0 vector 1) f28-3 f30-2) + (draw-thruster obj (the-as vector (-> s5-0 0)) (-> s5-0 0 vector 1) f28-3 f30-2) ) ) (when (logtest? (rigid-body-object-flag ignition) (-> obj flags)) diff --git a/goal_src/jak2/levels/city/common/vehicle-guard.gc b/goal_src/jak2/levels/city/common/vehicle-guard.gc index 6b20ae2205..5dc04d814e 100644 --- a/goal_src/jak2/levels/city/common/vehicle-guard.gc +++ b/goal_src/jak2/levels/city/common/vehicle-guard.gc @@ -106,24 +106,24 @@ (turret-control-method-9 (_type_ vehicle vector vector) none 9) (turret-control-method-10 (_type_ vehicle) none 10) (turret-control-method-11 (_type_ object object vector) none 11) - (turret-control-method-12 (_type_ joint-mod-rotate-local) none 12) + (update-joint-mod (_type_ joint-mod-rotate-local) none 12) (turret-control-method-13 (_type_) none 13) (turret-control-method-14 (_type_) none 14) - (turret-control-method-15 (_type_ turret-control-info) none 15) + (set-info (_type_ turret-control-info) none 15) (turret-control-method-16 (_type_ float float) none 16) (turret-control-method-17 (_type_ vehicle) none 17) ) ) -(defmethod turret-control-method-15 turret-control ((obj turret-control) (arg0 turret-control-info)) +(defmethod set-info turret-control ((obj turret-control) (arg0 turret-control-info)) (set! (-> obj info) arg0) (set! (-> obj owner-handle) (the-as handle #f)) 0 (none) ) -(defmethod turret-control-method-12 turret-control ((obj turret-control) (arg0 joint-mod-rotate-local)) +(defmethod update-joint-mod turret-control ((obj turret-control) (arg0 joint-mod-rotate-local)) (let ((v1-0 (new 'stack-no-clear 'vector))) (set! (-> v1-0 x) (- (-> obj aim-rot-x))) (set! (-> v1-0 y) (-> obj aim-rot-y)) @@ -815,7 +815,7 @@ (set! (-> a1-2 flags) (traffic-danger-flags tdf0)) (set! (-> a1-2 danger-type) (traffic-danger-type tdt6)) (set! (-> a1-2 handle) (the-as uint #f)) - (add-danger-sphere (-> obj controller traffic) a1-2) + (add-danger (-> obj controller traffic) a1-2) ) ) ) @@ -978,8 +978,8 @@ ) ) -(defmethod rigid-body-object-method-31 vehicle-guard ((obj vehicle-guard) (arg0 rigid-body-vehicle-constants)) - (let ((t9-0 (method-of-type vehicle rigid-body-object-method-31))) +(defmethod alloc-and-init-rigid-body-control vehicle-guard ((obj vehicle-guard) (arg0 rigid-body-vehicle-constants)) + (let ((t9-0 (method-of-type vehicle alloc-and-init-rigid-body-control))) (t9-0 obj arg0) ) (set! (-> obj mask) (logior (process-mask enemy guard) (-> obj mask))) diff --git a/goal_src/jak2/levels/city/common/vehicle-h.gc b/goal_src/jak2/levels/city/common/vehicle-h.gc index bbb11f7f32..ff23b57b52 100644 --- a/goal_src/jak2/levels/city/common/vehicle-h.gc +++ b/goal_src/jak2/levels/city/common/vehicle-h.gc @@ -377,7 +377,7 @@ :size-assert #x370 :flag-assert #x9002f00370 (:methods - (rigid-body-object-method-31 (_type_ rigid-body-vehicle-constants) none :replace 31) + (alloc-and-init-rigid-body-control (_type_ rigid-body-vehicle-constants) none :replace 31) (inactive () _type_ :state 53) (waiting () _type_ :state 54) (vehicle-method-55 () _type_ :state 55) @@ -390,16 +390,16 @@ (vehicle-method-62 (_type_ float) none 62) (vehicle-method-63 (_type_ float) none 63) (vehicle-method-64 () none 64) - (vehicle-method-65 (_type_) none 65) + (start-jump (_type_) none 65) (vehicle-method-66 () none 66) - (vehicle-method-67 (_type_) none 67) - (vehicle-method-68 (_type_ vector int) none 68) - (vehicle-method-69 (_type_ int) process 69) + (get-seat-count (_type_) int 67) + (compute-seat-position (_type_ vector int) none 68) + (get-rider-in-seat (_type_ int) process 69) (vehicle-method-70 (_type_) process 70) - (vehicle-method-71 (_type_ int process-focusable) none 71) + (put-rider-in-seat (_type_ int process-focusable) none 71) (vehicle-method-72 (_type_) uint 72) - (vehicle-method-73 (_type_ vector int int) int 73) - (vehicle-method-74 (_type_ process) none 74) + (get-best-seat-for-vehicle (_type_ vector int int) int 73) + (remove-rider (_type_ process) none 74) (vehicle-method-75 (_type_) float 75) (vehicle-method-76 (_type_ int uint) none 76) (vehicle-method-77 (_type_) none 77) @@ -409,9 +409,9 @@ (vehicle-method-81 (_type_) none 81) (vehicle-method-82 (_type_) none 82) (vehicle-method-83 (_type_) none 83) - (vehicle-method-84 (_type_ vector vector float float) none 84) - (vehicle-method-85 (_type_) none 85) - (vehicle-method-86 () none 86) + (draw-thruster (_type_ vector vector float float) none 84) + (draw-thrusters (_type_) none 85) + (update-joint-mods (_type_) none 86) (vehicle-method-87 (_type_) none 87) (vehicle-method-88 (_type_) none 88) (vehicle-method-89 (_type_) none 89) diff --git a/goal_src/jak2/levels/city/common/vehicle-physics.gc b/goal_src/jak2/levels/city/common/vehicle-physics.gc index 6a56c7ac3f..72e4315396 100644 --- a/goal_src/jak2/levels/city/common/vehicle-physics.gc +++ b/goal_src/jak2/levels/city/common/vehicle-physics.gc @@ -677,7 +677,7 @@ ) ) ) - (let ((s1-4 (new 'stack-no-clear 'inline-array 'vehicle-control-point 2))) + (let ((s1-4 (new 'stack-no-clear 'inline-array 'vehicle-control-point 24))) (quad-copy! (the-as pointer s1-4) (the-as pointer (-> s4-0 stabilizer-array)) diff --git a/goal_src/jak2/levels/city/common/vehicle-rider.gc b/goal_src/jak2/levels/city/common/vehicle-rider.gc index d4ccb455f5..072b016b05 100644 --- a/goal_src/jak2/levels/city/common/vehicle-rider.gc +++ b/goal_src/jak2/levels/city/common/vehicle-rider.gc @@ -53,7 +53,7 @@ (if (and s5-0 (nonzero? (vehicle-method-72 s5-0))) (logior! (-> obj flags) 4) ) - (vehicle-method-71 s5-0 (-> obj seat-index) obj) + (put-rider-in-seat s5-0 (-> obj seat-index) obj) ) (set! (-> obj anim-speed) (rand-vu-float-range 0.8 1.2)) 0 @@ -63,7 +63,7 @@ (defmethod vehicle-rider-method-35 vehicle-rider ((obj vehicle-rider)) (logior! (-> obj draw status) (draw-control-status no-draw)) (let ((v1-3 (-> obj parent-override))) - (vehicle-method-71 + (put-rider-in-seat (the-as vehicle (if v1-3 (-> v1-3 0 self-override) ) @@ -147,7 +147,7 @@ (('knocked-off) (let ((gp-0 (new 'stack 'traffic-object-spawn-params))) (let ((v1-14 (find-nearest-nav-mesh (-> self root-override trans) (the-as float #x7f800000)))) - (set! (-> gp-0 object-type) (the-as uint 0)) + (set! (-> gp-0 object-type) (traffic-type citizen-norm-1)) (set! (-> gp-0 behavior) (the-as uint 11)) (set! (-> gp-0 id) (the-as uint 0)) (set! (-> gp-0 nav-mesh) v1-14) @@ -161,7 +161,7 @@ (vector-reset! (-> gp-0 velocity)) (when (logtest? (-> self flags) 8) (send-event *traffic-manager* 'increase-alert-level 2) - (set! (-> gp-0 object-type) (the-as uint 6)) + (set! (-> gp-0 object-type) (traffic-type crimson-guard-1)) ) (set! (-> gp-0 position quad) (-> self root-override trans quad)) (quaternion-copy! (-> gp-0 rotation) (-> self root-override quat)) diff --git a/goal_src/jak2/levels/city/common/vehicle-states.gc b/goal_src/jak2/levels/city/common/vehicle-states.gc index 775db859e9..d80bad2c82 100644 --- a/goal_src/jak2/levels/city/common/vehicle-states.gc +++ b/goal_src/jak2/levels/city/common/vehicle-states.gc @@ -424,7 +424,7 @@ ) (send-event-function (handle->process (-> self rider-array gp-1)) a1-2) ) - (vehicle-method-71 self gp-1 (the-as process-focusable #f)) + (put-rider-in-seat self gp-1 (the-as process-focusable #f)) ) (logior! (-> self focus-status) (focus-status dead)) (set! (-> self crash-level) 3) diff --git a/goal_src/jak2/levels/city/common/vehicle-util.gc b/goal_src/jak2/levels/city/common/vehicle-util.gc index 463388f9f9..668936d539 100644 --- a/goal_src/jak2/levels/city/common/vehicle-util.gc +++ b/goal_src/jak2/levels/city/common/vehicle-util.gc @@ -246,9 +246,9 @@ This commonly includes things such as: (s4-1 #f) (s3-0 #f) ) - (let ((a2-2 (vehicle-method-73 obj (-> s5-0 matrices 0 vector 1) 1 0))) + (let ((a2-2 (get-best-seat-for-vehicle obj (-> s5-0 matrices 0 vector 1) 1 0))) (when (!= a2-2 -1) - (vehicle-method-68 obj (-> s5-0 matrices 0 vector 2) a2-2) + (compute-seat-position obj (-> s5-0 matrices 0 vector 2) a2-2) (vector+float*! (-> s5-0 matrices 0 vector 2) (-> s5-0 matrices 0 vector 2) @@ -442,7 +442,7 @@ This commonly includes things such as: (none) ) -(defmethod vehicle-method-65 vehicle ((obj vehicle)) +(defmethod start-jump vehicle ((obj vehicle)) (when (logtest? (-> obj info-override flags) 16) (when (not (logtest? (rigid-body-object-flag jump-sound) (-> obj flags))) (set! (-> obj flags) (logior (rigid-body-object-flag jump-sound) (-> obj flags))) @@ -459,12 +459,11 @@ This commonly includes things such as: (none) ) -(defmethod vehicle-method-67 vehicle ((obj vehicle)) +(defmethod get-seat-count vehicle ((obj vehicle)) (-> obj info-override seat-count) - (none) ) -(defmethod vehicle-method-68 vehicle ((obj vehicle) (arg0 vector) (arg1 int)) +(defmethod compute-seat-position vehicle ((obj vehicle) (arg0 vector) (arg1 int)) (let ((v1-0 (new 'stack-no-clear 'vector))) (set! (-> v1-0 quad) (-> obj info-override seat-array arg1 position quad)) (set! (-> v1-0 w) 1.0) @@ -474,7 +473,7 @@ This commonly includes things such as: (none) ) -(defmethod vehicle-method-69 vehicle ((obj vehicle) (arg0 int)) +(defmethod get-rider-in-seat vehicle ((obj vehicle) (arg0 int)) (let ((v0-0 (the-as process #f))) (if (< arg0 (-> obj info-override seat-count)) (set! v0-0 (handle->process (-> obj rider-array arg0))) @@ -487,7 +486,7 @@ This commonly includes things such as: (let ((gp-0 (the-as process #f))) (countdown (s4-0 (-> obj info-override seat-count)) (when (logtest? (-> obj info-override seat-array s4-0 flags) 1) - (let ((v1-7 (vehicle-method-69 obj s4-0))) + (let ((v1-7 (get-rider-in-seat obj s4-0))) (if v1-7 (set! gp-0 v1-7) ) @@ -498,7 +497,7 @@ This commonly includes things such as: ) ) -(defmethod vehicle-method-73 vehicle ((obj vehicle) (arg0 vector) (arg1 int) (arg2 int)) +(defmethod get-best-seat-for-vehicle vehicle ((obj vehicle) (arg0 vector) (arg1 int) (arg2 int)) (let ((gp-0 -1)) (let ((f30-0 (the-as float #x7f800000)) (s1-0 (new 'stack-no-clear 'vector)) @@ -511,16 +510,16 @@ This commonly includes things such as: #t ) ((= v1-7 1) - (not (vehicle-method-69 obj s0-0)) + (not (get-rider-in-seat obj s0-0)) ) ((= v1-7 2) - (vehicle-method-69 obj s0-0) + (get-rider-in-seat obj s0-0) ) (else #f ) ) - (vehicle-method-68 obj s1-0 s0-0) + (compute-seat-position obj s1-0 s0-0) (let ((f0-0 (vector-vector-distance-squared arg0 s1-0))) (when (< f0-0 f30-0) (set! f30-0 f0-0) @@ -536,7 +535,7 @@ This commonly includes things such as: ) ) -(defmethod vehicle-method-74 vehicle ((obj vehicle) (arg0 process)) +(defmethod remove-rider vehicle ((obj vehicle) (arg0 process)) (let ((v1-1 (-> obj info-override seat-count))) (dotimes (a2-0 v1-1) (if (= arg0 (handle->process (-> obj rider-array a2-0))) @@ -548,7 +547,7 @@ This commonly includes things such as: (none) ) -(defmethod vehicle-method-71 vehicle ((obj vehicle) (arg0 int) (arg1 process-focusable)) +(defmethod put-rider-in-seat vehicle ((obj vehicle) (arg0 int) (arg1 process-focusable)) (if (< arg0 (-> obj info-override seat-count)) (set! (-> obj rider-array arg0) (process->handle arg1)) ) @@ -695,7 +694,7 @@ This commonly includes things such as: (set! (-> obj power-level) 1.0) (set! (-> obj flight-level-index) 0) (let ((a1-0 (-> obj root-override-2 trans))) - (set! (-> obj flight-level) (xz-height-map-method-9 *traffic-height-map* a1-0)) + (set! (-> obj flight-level) (get-height-at-point *traffic-height-map* a1-0)) ) (set! (-> obj lights-factor) 0.0) (let ((a0-8 (-> obj info-override color-option-select))) @@ -1076,7 +1075,7 @@ This commonly includes things such as: (let ((a0-1 (-> obj controller traffic))) (when (and (nonzero? a0-1) arg1) (if #t - (increase-alert-level a0-1 arg0 arg1) + (increase-alert-level a0-1 (the-as int arg0) arg1) ) ) ) @@ -1085,7 +1084,7 @@ This commonly includes things such as: ) (defmethod vehicle-method-112 vehicle ((obj vehicle) (arg0 object)) - (decrease-alert-level (-> obj controller traffic) arg0) + (decrease-alert-level (-> obj controller traffic) (the-as int arg0)) 0 (none) ) @@ -1245,7 +1244,7 @@ This commonly includes things such as: ) ) (dotimes (s5-1 (-> obj info-override seat-count)) - (vehicle-method-71 obj s5-1 (the-as process-focusable #f)) + (put-rider-in-seat obj s5-1 (the-as process-focusable #f)) ) (vehicle-method-142 obj) (vehicle-controller-method-11 (-> obj controller)) @@ -1371,7 +1370,7 @@ This commonly includes things such as: ) ) -(defmethod vehicle-method-86 vehicle () +(defmethod update-joint-mods vehicle ((obj vehicle)) 0 (none) ) @@ -1385,7 +1384,7 @@ This commonly includes things such as: (set! (-> s5-0 local-pos w) 40960.0) (let ((s4-0 0)) (label cfg-1) - (let ((v1-7 (traffic-engine-method-20 (-> obj controller traffic) (-> s5-0 local-pos) (-> s5-0 normal) 0))) + (let ((v1-7 (find-best-segment (-> obj controller traffic) (-> s5-0 local-pos) (-> s5-0 normal) 0))) (when (and (not v1-7) (< s4-0 3)) (set! (-> s5-0 local-pos w) (+ 40960.0 (-> s5-0 local-pos w))) (+! s4-0 1) @@ -1406,7 +1405,7 @@ This commonly includes things such as: (dotimes (s5-0 (-> obj info-override seat-count)) (let ((s4-0 (handle->process (-> obj rider-array s5-0)))) (when (and s4-0 (logtest? (-> (the-as vehicle-rider s4-0) focus-status) (focus-status pilot-riding))) - (vehicle-method-68 obj (-> (the-as vehicle-rider s4-0) root-override trans) s5-0) + (compute-seat-position obj (-> (the-as vehicle-rider s4-0) root-override trans) s5-0) (set! (-> (the-as vehicle-rider s4-0) root-override transv quad) (-> obj root-override-2 transv quad)) (let ((f0-1 (the float (-> obj info-override seat-array s5-0 angle)))) (quaternion-rotate-local-y! diff --git a/goal_src/jak2/levels/city/common/vehicle.gc b/goal_src/jak2/levels/city/common/vehicle.gc index bb14c3106e..9146e16bbd 100644 --- a/goal_src/jak2/levels/city/common/vehicle.gc +++ b/goal_src/jak2/levels/city/common/vehicle.gc @@ -192,7 +192,7 @@ (with-pp (when (= (-> obj controller traffic sync-mask-8) (ash 1 (logand (-> obj traffic-priority-id) 7))) (let ((a1-0 (-> obj root-override-2 trans))) - (set! (-> obj flight-level) (xz-height-map-method-9 *traffic-height-map* a1-0)) + (set! (-> obj flight-level) (get-height-at-point *traffic-height-map* a1-0)) ) ) (set! (-> obj target-acceleration y) @@ -394,7 +394,7 @@ (vehicle-method-95 obj (the-as vector (&-> s5-0 x))) ) (if (or (cpad-hold? 0 l1) (and (logtest? (-> obj info-override flags) 512) (cpad-hold? 0 r1))) - (vehicle-method-65 obj) + (start-jump obj) ) (if (cpad-pressed? 0 circle) ((method-of-object obj vehicle-method-66)) @@ -592,10 +592,10 @@ (dotimes (v1-4 (-> *level* length)) (let ((a0-5 (-> *level* level v1-4))) (when (= (-> a0-5 status) 'active) - (let ((a0-7 (-> a0-5 bsp bsp-header-jkh1b23))) + (let ((a0-7 (-> a0-5 bsp city-level-info))) (when (nonzero? a0-7) - (let ((f1-0 (-> a0-7 frames-per-second))) - (if (= f1-0 0.0) + (let ((f1-0 (the-as float (-> a0-7 camera-ceiling)))) + (if (= (the-as meters f1-0) 0.0) (set! f1-0 40960000.0) ) (set! f0-0 (fmax f0-0 f1-0)) @@ -906,18 +906,18 @@ (f1-0 245760.0) ) (if (< f0-1 (* f1-0 f1-0)) - (rigid-body-object-method-36 obj) + (do-engine-sounds obj) ) ) (when (logtest? (-> obj draw status) (draw-control-status on-screen)) (if #t - (vehicle-method-85 obj) + (draw-thrusters obj) ) (let ((f0-2 (-> obj camera-dist2)) (f1-3 245760.0) ) (if (< f0-2 (* f1-3 f1-3)) - ((method-of-object obj vehicle-method-86)) + (update-joint-mods obj) ) ) ) @@ -992,7 +992,7 @@ ) (vehicle-method-96 obj) (let ((a1-0 (-> obj rbody state position))) - (set! (-> obj flight-level) (xz-height-map-method-9 *traffic-height-map* a1-0)) + (set! (-> obj flight-level) (get-height-at-point *traffic-height-map* a1-0)) ) 0 (none) @@ -1275,13 +1275,13 @@ (let ((f0-10 (vector-length (-> obj root-override-2 transv)))) (seek! (-> obj engine-power-factor) (* 0.000016276043 f0-10) (* 6.0 (-> pp clock seconds-per-frame))) ) - (rigid-body-object-method-36 obj) + (do-engine-sounds obj) ) ) (when (logtest? (-> obj draw status) (draw-control-status on-screen)) (when #t (set! (-> obj node-list data 0 bone transform trans quad) (-> obj root-override-2 trans quad)) - (vehicle-method-85 obj) + (draw-thrusters obj) ) ) (let ((v1-70 (-> *perf-stats* data 19))) @@ -1357,7 +1357,7 @@ (none) ) -(defmethod rigid-body-object-method-31 vehicle ((obj vehicle) (arg0 rigid-body-vehicle-constants)) +(defmethod alloc-and-init-rigid-body-control vehicle ((obj vehicle) (arg0 rigid-body-vehicle-constants)) (if (logtest? (-> arg0 flags) 8) (iterate-prims (-> obj root-override-2) @@ -1443,7 +1443,7 @@ (new 'static 'pat-surface :noentity #x1 :nopilot #x1 :probe #x1) ) (set! (-> obj root-override-2 event-self) 'touched) - (let ((t9-3 (method-of-type rigid-body-object rigid-body-object-method-31))) + (let ((t9-3 (method-of-type rigid-body-object alloc-and-init-rigid-body-control))) (t9-3 obj arg0) ) (logior! (-> obj rbody state flags) (rigid-body-flag enable-collision)) @@ -1857,7 +1857,7 @@ (when s5-3 (format #t "vehicle::event-handler: pilot-on (pid ~d) from pid ~d~%" (-> obj pid) (-> arg0 pid)) (logior! (-> obj flags) (rigid-body-object-flag riding)) - (vehicle-method-71 obj (the-as int s3-2) (the-as process-focusable s5-3)) + (put-rider-in-seat obj (the-as int s3-2) (the-as process-focusable s5-3)) (if (logtest? (-> s5-3 mask) (process-mask target)) (logior! (-> obj flags) (rigid-body-object-flag player-driving)) ) @@ -1894,13 +1894,13 @@ (defbehavior vehicle-init-by-other vehicle ((arg0 traffic-object-spawn-params)) (stack-size-set! (-> self main-thread) 16) (set! (-> self mask) (logior (process-mask vehicle) (-> self mask))) - (rigid-body-object-method-32 self) + (allocate-and-init-cshape self) (set! (-> self root-override-2 trans quad) (-> arg0 position quad)) (quaternion-copy! (-> self root-override-2 quat) (-> arg0 rotation)) (if (not (logtest? (-> arg0 flags) 1)) (lwide-entity-hack) ) - (rigid-body-object-method-33 self) + (init-skel-and-rigid-body self) (set! (-> self traffic-priority-id) (the-as int (-> arg0 id))) (vehicle-method-136 self arg0) (none) diff --git a/goal_src/jak2/levels/city/misc/collection_task/collection-task.gc b/goal_src/jak2/levels/city/misc/collection_task/collection-task.gc index ad64aae5aa..f4fe866d64 100644 --- a/goal_src/jak2/levels/city/misc/collection_task/collection-task.gc +++ b/goal_src/jak2/levels/city/misc/collection_task/collection-task.gc @@ -219,7 +219,7 @@ ) (set! (-> traffic-obj-params position quad) (-> self begin-pos quad)) (quaternion-axis-angle! (-> traffic-obj-params rotation) 0.0 1.0 0.0 16384.0) - (set! (-> traffic-obj-params object-type) (the-as uint 13)) + (set! (-> traffic-obj-params object-type) (traffic-type bikec)) (set! (-> traffic-obj-params behavior) (the-as uint 0)) (set! (-> traffic-obj-params id) (the-as uint 0)) (set! (-> traffic-obj-params proc) #f) diff --git a/goal_src/jak2/levels/city/misc/delivery/delivery-task.gc b/goal_src/jak2/levels/city/misc/delivery/delivery-task.gc index 6a3cb31797..ac42e4ed1a 100644 --- a/goal_src/jak2/levels/city/misc/delivery/delivery-task.gc +++ b/goal_src/jak2/levels/city/misc/delivery/delivery-task.gc @@ -116,6 +116,7 @@ This commonly includes things such as: (none) ) +;; WARN: Return type mismatch (pointer process) vs (pointer krew-package). (defun krew-package-spawn ((arg0 process) (arg1 process)) (process-spawn krew-package arg1 :to arg0) ) @@ -142,7 +143,7 @@ This commonly includes things such as: (let ((s5-0 (new 'stack 'traffic-object-spawn-params))) (set! (-> s5-0 position quad) (-> (new 'static 'vector :x 4698112.0 :y 45875.2 :z 81920.0 :w 1.0) quad)) (quaternion-axis-angle! (-> s5-0 rotation) 0.0 1.0 0.0 32768.0) - (set! (-> s5-0 object-type) (the-as uint 11)) + (set! (-> s5-0 object-type) (traffic-type bikea)) (set! (-> s5-0 behavior) (the-as uint 0)) (set! (-> s5-0 id) (the-as uint 0)) (set! (-> s5-0 proc) #f) @@ -248,7 +249,7 @@ This commonly includes things such as: ) (s5-0 (new 'stack-no-clear 'traffic-object-spawn-params)) ) - (set! (-> s5-0 object-type) (the-as uint 6)) + (set! (-> s5-0 object-type) (traffic-type crimson-guard-1)) (set! (-> s5-0 behavior) (the-as uint 9)) (set! (-> s5-0 id) (the-as uint 0)) (set! (-> s5-0 nav-mesh) #f) @@ -320,7 +321,7 @@ This commonly includes things such as: ) (s5-0 (new 'stack-no-clear 'traffic-object-spawn-params)) ) - (set! (-> s5-0 object-type) (the-as uint 6)) + (set! (-> s5-0 object-type) (traffic-type crimson-guard-1)) (set! (-> s5-0 behavior) (the-as uint 9)) (set! (-> s5-0 id) (the-as uint 0)) (set! (-> s5-0 nav-mesh) #f) diff --git a/goal_src/jak2/levels/city/port/mines/portrun.gc b/goal_src/jak2/levels/city/port/mines/portrun.gc index 1b1141a0b5..1a7a2bf1f4 100644 --- a/goal_src/jak2/levels/city/port/mines/portrun.gc +++ b/goal_src/jak2/levels/city/port/mines/portrun.gc @@ -1676,7 +1676,7 @@ ) (set! (-> s5-0 position quad) (-> self begin-pos quad)) (quaternion-axis-angle! (-> s5-0 rotation) 0.0 1.0 0.0 0.0) - (set! (-> s5-0 object-type) (the-as uint 13)) + (set! (-> s5-0 object-type) (traffic-type bikec)) (set! (-> s5-0 behavior) (the-as uint 0)) (set! (-> s5-0 id) (the-as uint 0)) (set! (-> s5-0 proc) #f) diff --git a/goal_src/jak2/levels/city/side_missions/ctywide-bbush.gc b/goal_src/jak2/levels/city/side_missions/ctywide-bbush.gc index 65c0fae014..4d8872bacf 100644 --- a/goal_src/jak2/levels/city/side_missions/ctywide-bbush.gc +++ b/goal_src/jak2/levels/city/side_missions/ctywide-bbush.gc @@ -1440,7 +1440,7 @@ ) (set! (-> gp-0 position quad) (-> *bb-ring-info* (-> self info index) start-pos quad)) (quaternion-axis-angle! (-> gp-0 rotation) 0.0 1.0 0.0 (-> *bb-ring-info* (-> self info index) rotation)) - (set! (-> gp-0 object-type) (the-as uint 11)) + (set! (-> gp-0 object-type) (traffic-type bikea)) (set! (-> gp-0 behavior) (the-as uint 0)) (set! (-> gp-0 id) (the-as uint 0)) (set! (-> gp-0 proc) #f) @@ -1827,14 +1827,17 @@ This commonly includes things such as: (none) ) +;; WARN: Return type mismatch (pointer process) vs (pointer bush-collect). (defun bush-collect-spawn ((arg0 task-manager) (arg1 vector)) (process-spawn bush-collect arg1 :to arg0) ) +;; WARN: Return type mismatch (pointer process) vs (pointer bush-collect). (defun bush-collect-homing-beacon-spawn ((arg0 task-manager) (arg1 vector)) (process-spawn bush-collect :init bush-collect-homing-beacon-init-by-other arg1 :to arg0) ) +;; WARN: Return type mismatch (pointer process) vs (pointer bush-collect). (defun bush-collect-dark-eco-spawn ((arg0 task-manager) (arg1 vector)) (process-spawn bush-collect :init bush-collect-dark-eco-init-by-other arg1 :to arg0) ) diff --git a/goal_src/jak2/levels/dig/dig-obs.gc b/goal_src/jak2/levels/dig/dig-obs.gc index 72fb580697..14a01952e0 100644 --- a/goal_src/jak2/levels/dig/dig-obs.gc +++ b/goal_src/jak2/levels/dig/dig-obs.gc @@ -36,7 +36,7 @@ (none) ) -(defmethod rigid-body-object-method-32 dig-sinking-plat ((obj dig-sinking-plat)) +(defmethod allocate-and-init-cshape dig-sinking-plat ((obj dig-sinking-plat)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -236,13 +236,13 @@ :event (-> (method-of-type dig-sinking-plat idle) event) ) -(defmethod rigid-body-object-method-33 dig-sinking-plat ((obj dig-sinking-plat)) +(defmethod init-skel-and-rigid-body dig-sinking-plat ((obj dig-sinking-plat)) (initialize-skeleton obj (the-as skeleton-group (art-group-get-by-name *level* "skel-dig-sinking-plat" (the-as (pointer uint32) #f))) (the-as pair 0) ) - (rigid-body-object-method-31 obj *dig-sinking-platform-constants*) + (alloc-and-init-rigid-body-control obj *dig-sinking-platform-constants*) (set! (-> obj anchor-point quad) (-> obj root-override-2 trans quad)) (set! (-> obj surface-height) (+ -4096.0 (-> obj root-override-2 trans y))) (let ((s5-1 (-> obj info-override control-point-count))) diff --git a/goal_src/jak2/levels/dig/dig1-obs.gc b/goal_src/jak2/levels/dig/dig1-obs.gc index 968462eefc..49bc869dc7 100644 --- a/goal_src/jak2/levels/dig/dig1-obs.gc +++ b/goal_src/jak2/levels/dig/dig1-obs.gc @@ -710,7 +710,7 @@ ) ) -(defmethod rigid-body-object-method-32 dig-bomb-crate-cylinder ((obj dig-bomb-crate-cylinder)) +(defmethod allocate-and-init-cshape dig-bomb-crate-cylinder ((obj dig-bomb-crate-cylinder)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -759,7 +759,7 @@ (none) ) -(defmethod rigid-body-object-method-33 dig-bomb-crate-cylinder ((obj dig-bomb-crate-cylinder)) +(defmethod init-skel-and-rigid-body dig-bomb-crate-cylinder ((obj dig-bomb-crate-cylinder)) (initialize-skeleton obj (the-as @@ -768,7 +768,7 @@ ) (the-as pair 0) ) - (rigid-body-object-method-31 obj *dig-bomb-crate-cylinder-constants*) + (alloc-and-init-rigid-body-control obj *dig-bomb-crate-cylinder-constants*) (logclear! (-> obj mask) (process-mask actor-pause)) (logior! (-> obj rbody state flags) (rigid-body-flag enable-collision)) (set! (-> obj draw light-index) (the-as uint 10)) @@ -779,10 +779,10 @@ ;; WARN: Return type mismatch object vs none. (defbehavior dig-bomb-crate-cylinder-init-by-other dig-bomb-crate-cylinder ((arg0 dig-bomb-crate-cylinder-spawn-params) (arg1 entity-actor)) (process-entity-set! self arg1) - (rigid-body-object-method-32 self) + (allocate-and-init-cshape self) (set! (-> self root-override-2 trans quad) (-> arg0 pos quad)) (quaternion-copy! (-> self root-override-2 quat) (-> arg0 quat)) - (rigid-body-object-method-33 self) + (init-skel-and-rigid-body self) (set! (-> self mask) (logior (process-mask platform) (-> self mask))) (vector-float*! (-> self rbody state lin-momentum) (-> arg0 vel) (-> self info info mass)) (vector-float*! (-> self rbody state ang-momentum) (-> arg0 avel) (-> self info info mass)) diff --git a/goal_src/jak2/levels/dig/dig3-obs.gc b/goal_src/jak2/levels/dig/dig3-obs.gc index a25056fbbf..f6806a5d07 100644 --- a/goal_src/jak2/levels/dig/dig3-obs.gc +++ b/goal_src/jak2/levels/dig/dig3-obs.gc @@ -1437,7 +1437,7 @@ This commonly includes things such as: (none) ) -(defmethod rigid-body-object-method-32 dig-tipping-rock ((obj dig-tipping-rock)) +(defmethod allocate-and-init-cshape dig-tipping-rock ((obj dig-tipping-rock)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -1469,14 +1469,14 @@ This commonly includes things such as: (-> obj surface-height) ) -(defmethod rigid-body-object-method-33 dig-tipping-rock ((obj dig-tipping-rock)) +(defmethod init-skel-and-rigid-body dig-tipping-rock ((obj dig-tipping-rock)) (initialize-skeleton obj (the-as skeleton-group (art-group-get-by-name *level* "skel-dig-tipping-rock" (the-as (pointer uint32) #f))) (the-as pair 0) ) (quaternion-rotate-local-x! (-> obj root-override-2 quat) (-> obj root-override-2 quat) -2555.2202) - (rigid-body-object-method-31 obj *dig-tipping-rock-constants*) + (alloc-and-init-rigid-body-control obj *dig-tipping-rock-constants*) (set! (-> obj anchor-point quad) (-> obj rbody state position quad)) (let ((v1-8 (-> obj control-point-array))) (let ((a0-8 (-> v1-8 data))) @@ -1770,7 +1770,7 @@ This commonly includes things such as: ) ) -(defmethod rigid-body-object-method-32 dig-stomp-block ((obj dig-stomp-block)) +(defmethod allocate-and-init-cshape dig-stomp-block ((obj dig-stomp-block)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -1865,13 +1865,13 @@ This commonly includes things such as: (none) ) -(defmethod rigid-body-object-method-33 dig-stomp-block ((obj dig-stomp-block)) +(defmethod init-skel-and-rigid-body dig-stomp-block ((obj dig-stomp-block)) (initialize-skeleton obj (the-as skeleton-group (art-group-get-by-name *level* "skel-dig-stomp-block" (the-as (pointer uint32) #f))) (the-as pair 0) ) - (rigid-body-object-method-31 obj *dig-stomp-block-constants*) + (alloc-and-init-rigid-body-control obj *dig-stomp-block-constants*) (logclear! (-> obj mask) (process-mask actor-pause)) (logior! (-> obj rbody state flags) (rigid-body-flag enable-collision)) (set! (-> obj draw light-index) (the-as uint 10)) @@ -1883,10 +1883,10 @@ This commonly includes things such as: ;; WARN: Return type mismatch object vs none. (defbehavior dig-stomp-block-init-by-other dig-stomp-block ((arg0 vector)) (set! (-> self mask) (logior (process-mask platform) (-> self mask))) - (rigid-body-object-method-32 self) + (allocate-and-init-cshape self) (set! (-> self root-override-2 trans quad) (-> arg0 quad)) (set-vector! (-> self root-override-2 quat) 0.0 1.0 0.0 0.0) - (rigid-body-object-method-33 self) + (init-skel-and-rigid-body self) (transform-post) (go-virtual waiting) (none) diff --git a/goal_src/jak2/levels/ruins/ruins-obs.gc b/goal_src/jak2/levels/ruins/ruins-obs.gc index 269dbe2d3b..ec072fdb46 100644 --- a/goal_src/jak2/levels/ruins/ruins-obs.gc +++ b/goal_src/jak2/levels/ruins/ruins-obs.gc @@ -29,7 +29,7 @@ (none) ) -(defmethod rigid-body-object-method-32 sinking-plat ((obj sinking-plat)) +(defmethod allocate-and-init-cshape sinking-plat ((obj sinking-plat)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -90,14 +90,14 @@ ) ) -(defmethod rigid-body-object-method-33 sinking-plat ((obj sinking-plat)) +(defmethod init-skel-and-rigid-body sinking-plat ((obj sinking-plat)) (initialize-skeleton obj (the-as skeleton-group (art-group-get-by-name *level* "skel-sinking-plat" (the-as (pointer uint32) #f))) (the-as pair 0) ) (set! (-> obj float-height-offset) 4096.0) - (rigid-body-object-method-31 obj *ruins-sinking-platform-constants*) + (alloc-and-init-rigid-body-control obj *ruins-sinking-platform-constants*) (set! (-> obj anchor-point quad) (-> obj root-override-2 trans quad)) (let ((s5-1 (-> obj info-override control-point-count))) (dotimes (s4-1 s5-1) diff --git a/goal_src/jak2/levels/underport/under-obs.gc b/goal_src/jak2/levels/underport/under-obs.gc index cd1fb4e2fe..08592075db 100644 --- a/goal_src/jak2/levels/underport/under-obs.gc +++ b/goal_src/jak2/levels/underport/under-obs.gc @@ -894,7 +894,7 @@ This commonly includes things such as: (none) ) -(defmethod rigid-body-object-method-32 under-buoy-plat ((obj under-buoy-plat)) +(defmethod allocate-and-init-cshape under-buoy-plat ((obj under-buoy-plat)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -978,13 +978,13 @@ This commonly includes things such as: (none) ) -(defmethod rigid-body-object-method-33 under-buoy-plat ((obj under-buoy-plat)) +(defmethod init-skel-and-rigid-body under-buoy-plat ((obj under-buoy-plat)) (initialize-skeleton obj (the-as skeleton-group (art-group-get-by-name *level* "skel-under-buoy-plat" (the-as (pointer uint32) #f))) (the-as pair 0) ) - (rigid-body-object-method-31 obj *under-buoy-plat-platform-constants*) + (alloc-and-init-rigid-body-control obj *under-buoy-plat-platform-constants*) (set! (-> obj orig-trans quad) (-> obj root-override-2 trans quad)) (set! (-> obj anchor-point quad) (-> obj root-override-2 trans quad)) (set! (-> obj surface-height) (-> obj root-override-2 trans y)) diff --git a/goalc/compiler/compilation/Type.cpp b/goalc/compiler/compilation/Type.cpp index e8753b4e2f..78d84db984 100644 --- a/goalc/compiler/compilation/Type.cpp +++ b/goalc/compiler/compilation/Type.cpp @@ -1141,15 +1141,20 @@ Val* Compiler::compile_stack_new(const goos::Object& form, if (!info.can_deref) { throw_compiler_error(form, "Cannot make an {} of {}\n", type_of_object.print(), ts.print()); } - auto type_info = m_ts.lookup_type(ts.get_single_arg()); - if (!m_ts.lookup_type(elt_type)->is_reference()) { + auto type_info = m_ts.lookup_type_allow_partial_def(ts.get_single_arg()); + if (!m_ts.lookup_type_allow_partial_def(elt_type)->is_reference()) { // not a reference type + m_ts.lookup_type(elt_type); // should be fully defined int size_in_bytes = info.stride * constant_count; auto addr = fe->allocate_aligned_stack_variable(ts, size_in_bytes, type_info->get_in_memory_alignment()); return addr; } + if (is_inline) { + m_ts.lookup_type(elt_type); // should be fully defined + } + int stride = is_inline ? align(type_info->get_size_in_memory(), type_info->get_inline_array_stride_alignment()) : 4; diff --git a/test/decompiler/reference/jak2/engine/ai/traffic-h_REF.gc b/test/decompiler/reference/jak2/engine/ai/traffic-h_REF.gc index fbf0fcf869..c6ad6601a7 100644 --- a/test/decompiler/reference/jak2/engine/ai/traffic-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/ai/traffic-h_REF.gc @@ -58,10 +58,10 @@ :size-assert #x29 :flag-assert #xd00000029 (:methods - (traffic-suppression-params-method-9 (_type_) symbol 9) - (traffic-suppression-params-method-10 (_type_) symbol 10) + (try-creating-new-suppression-box (_type_) symbol 9) + (create-or-update-suppression-box (_type_) symbol 10) (has-valid-id? (_type_) none 11) - (traffic-suppression-params-method-12 (_type_) none 12) + (kill-suppression-box (_type_) none 12) ) ) @@ -88,19 +88,19 @@ ;; definition of type traffic-object-spawn-params (deftype traffic-object-spawn-params (structure) - ((object-type uint8 :offset-assert 0) - (behavior uint64 :offset-assert 8) - (id uint32 :offset-assert 16) - (nav-mesh nav-mesh :offset-assert 20) - (nav-branch nav-branch :offset-assert 24) - (position vector :inline :offset-assert 32) - (rotation quaternion :inline :offset-assert 48) - (velocity vector :inline :offset-assert 64) - (handle uint64 :offset-assert 80) - (guard-type uint8 :offset-assert 88) - (user-data uint32 :offset-assert 92) - (flags uint32 :offset-assert 96) - (proc process :offset-assert 100) + ((object-type traffic-type :offset-assert 0) + (behavior uint64 :offset-assert 8) + (id uint32 :offset-assert 16) + (nav-mesh nav-mesh :offset-assert 20) + (nav-branch nav-branch :offset-assert 24) + (position vector :inline :offset-assert 32) + (rotation quaternion :inline :offset-assert 48) + (velocity vector :inline :offset-assert 64) + (handle uint64 :offset-assert 80) + (guard-type uint8 :offset-assert 88) + (user-data uint32 :offset-assert 92) + (flags uint32 :offset-assert 96) + (proc process :offset-assert 100) ) :method-count-assert 9 :size-assert #x68 diff --git a/test/decompiler/reference/jak2/engine/anim/joint-exploder_REF.gc b/test/decompiler/reference/jak2/engine/anim/joint-exploder_REF.gc index 1127ab6956..8dcb3a50eb 100644 --- a/test/decompiler/reference/jak2/engine/anim/joint-exploder_REF.gc +++ b/test/decompiler/reference/jak2/engine/anim/joint-exploder_REF.gc @@ -84,7 +84,7 @@ (deftype joint-exploder-static-params (basic) ((joints (array joint-exploder-static-joint-params) :offset-assert 4) (collide-spec uint32 :offset-assert 8) - (art-level basic :offset-assert 12) + (art-level symbol :offset-assert 12) ) :method-count-assert 9 :size-assert #x10 diff --git a/test/decompiler/reference/jak2/engine/common_objs/rigid-body-plat_REF.gc b/test/decompiler/reference/jak2/engine/common_objs/rigid-body-plat_REF.gc index 604d5e7c6f..f14afcf58e 100644 --- a/test/decompiler/reference/jak2/engine/common_objs/rigid-body-plat_REF.gc +++ b/test/decompiler/reference/jak2/engine/common_objs/rigid-body-plat_REF.gc @@ -455,7 +455,7 @@ ;; definition for method 31 of type rigid-body-platform ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-31 rigid-body-platform ((obj rigid-body-platform) (arg0 rigid-body-object-constants)) +(defmethod alloc-and-init-rigid-body-control rigid-body-platform ((obj rigid-body-platform) (arg0 rigid-body-object-constants)) (with-pp (set! (-> obj info-override) (the-as rigid-body-platform-constants arg0)) (set! (-> obj rbody) (new 'process 'rigid-body-control obj)) @@ -485,7 +485,7 @@ ;; definition for method 32 of type rigid-body-platform ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-32 rigid-body-platform ((obj rigid-body-platform)) +(defmethod allocate-and-init-cshape rigid-body-platform ((obj rigid-body-platform)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -550,9 +550,9 @@ ;; definition for method 33 of type rigid-body-platform ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-33 rigid-body-platform ((obj rigid-body-platform)) +(defmethod init-skel-and-rigid-body rigid-body-platform ((obj rigid-body-platform)) (set! (-> obj float-height-offset) 0.0) - (rigid-body-object-method-31 obj *rigid-body-platform-constants*) + (alloc-and-init-rigid-body-control obj *rigid-body-platform-constants*) (let ((s5-0 (-> obj info-override control-point-count))) (dotimes (s4-0 s5-0) (let ((s3-0 (-> obj control-point-array data s4-0))) @@ -579,9 +579,9 @@ This commonly includes things such as: - loading the skeleton group / bones - sounds" (set! (-> obj mask) (logior (process-mask platform) (-> obj mask))) - (rigid-body-object-method-32 obj) + (allocate-and-init-cshape obj) (process-drawable-from-entity! obj arg0) - (rigid-body-object-method-33 obj) + (init-skel-and-rigid-body obj) (rigid-body-object-method-34 obj) 0 (none) diff --git a/test/decompiler/reference/jak2/engine/debug/nav/mysql-nav-graph_REF.gc b/test/decompiler/reference/jak2/engine/debug/nav/mysql-nav-graph_REF.gc index a1f12159ca..7280ec743b 100644 --- a/test/decompiler/reference/jak2/engine/debug/nav/mysql-nav-graph_REF.gc +++ b/test/decompiler/reference/jak2/engine/debug/nav/mysql-nav-graph_REF.gc @@ -102,7 +102,7 @@ (width float :offset-assert 60) (minimap_edge_flag nav-minimap-edge-flag :offset-assert 64) ) - :pack-me + :allow-misaligned :method-count-assert 10 :size-assert #x44 :flag-assert #xa00000044 @@ -229,7 +229,7 @@ ;; definition of type mysql-nav-graph-level-info (deftype mysql-nav-graph-level-info (structure) - ((level string :offset-assert 0) + ((level symbol :offset-assert 0) (level-id uint32 :offset-assert 4) (node-count int32 :offset-assert 8) (branch-count int32 :offset-assert 12) @@ -367,7 +367,7 @@ otherwise, return the new size of the array" -1 ) (else - (let ((v1-5 (the-as mysql-nav-edge (+ (+ (* 80 (-> obj edge-array length)) 12) (the-as int (-> obj edge-array))))) + (let ((v1-5 (-> obj edge-array data (-> obj edge-array length))) (v0-1 (-> obj edge-array length)) ) (+! (-> obj edge-array length) 1) @@ -816,7 +816,7 @@ returns `-1` if none is found" "Iterate through the `edge-array` and return the index for the first [[mysql-nav-edge]] whom's `nav_edge_id` matches the provided id returns `-1` if none is found" (dotimes (v1-0 (-> obj edge-array length)) - (if (= edge-id (-> (the-as mysql-nav-edge (+ (+ (* 80 v1-0) 12) (the-as int (-> obj edge-array)))) nav_edge_id)) + (if (= edge-id (-> (the-as mysql-nav-edge (-> obj edge-array data v1-0)) nav_edge_id)) (return v1-0) ) ) @@ -958,10 +958,7 @@ returns `-1` if none is found" (set! sv-32 (string->int (-> s3-3 data (+ s2-2 2)))) (set! sv-48 (indexof-nav-node obj s0-2)) (set! sv-64 (indexof-nav-node obj sv-32)) - (let ((nav-edge - (the-as mysql-nav-edge (+ (+ (* 80 (-> obj edge-array length)) 12) (the-as int (-> obj edge-array)))) - ) - ) + (let ((nav-edge (-> obj edge-array data (-> obj edge-array length)))) (when (and (!= sv-48 -1) (!= sv-64 -1)) (set! (-> nav-edge nav_graph_id) (-> obj nav_graph_id)) (set! (-> nav-edge nav_edge_id) (the-as uint (string->int (-> s3-3 data s2-2)))) @@ -1190,10 +1187,10 @@ returns `-1` if none is found" ) ) (dotimes (v1-3 (-> obj edge-array length)) - (set! (-> (the-as mysql-nav-edge (+ (+ (* 80 v1-3) 12) (the-as int (-> obj edge-array)))) temp-next-edge) #f) + (set! (-> (the-as mysql-nav-edge (-> obj edge-array data v1-3)) temp-next-edge) #f) ) (countdown (v1-7 (-> obj edge-array length)) - (let ((a1-17 (the-as mysql-nav-edge (+ (+ (* 80 v1-7) 12) (the-as int (-> obj edge-array)))))) + (let ((a1-17 (-> obj edge-array data v1-7))) (when (not (logtest? (-> a1-17 mysql-save-flag) (mysql-save-flag delete))) (let ((a2-8 (-> obj node-array data (-> a1-17 runtime-node-id-1)))) (when (not (logtest? (-> a2-8 mysql-save-flag) (mysql-save-flag delete))) @@ -1253,7 +1250,7 @@ returns `-1` if none is found" (set! (-> obj level-info-last-lookup) v1-9) ) (set! s5-0 (-> obj level-info-array v1-9)) - (set! (-> s5-0 level) (the-as string (-> arg0 level_name))) + (set! (-> s5-0 level) (-> arg0 level_name)) (set! (-> s5-0 node-count) 0) (+! (-> obj level-info-array-length) 1) ) @@ -1346,7 +1343,7 @@ returns `-1` if none is found" (format #t "Done.~%") (format #t "Saving edges ...~%") (dotimes (s5-1 (-> obj edge-array length)) - (let ((a0-7 (the-as mysql-nav-edge (+ (+ (* 80 s5-1) 12) (the-as int (-> obj edge-array)))))) + (let ((a0-7 (-> obj edge-array data s5-1))) (set! (-> a0-7 nav_graph_id) (-> obj nav_graph_id)) (set! (-> a0-7 nav_node_id_1) (-> obj node-array data (-> a0-7 runtime-node-id-1) nav_node_id)) (set! (-> a0-7 nav_node_id_2) (-> obj node-array data (-> a0-7 runtime-node-id-2) nav_node_id)) diff --git a/test/decompiler/reference/jak2/engine/game/pilot-h_REF.gc b/test/decompiler/reference/jak2/engine/game/pilot-h_REF.gc index 79ff477dfe..9795d8105c 100644 --- a/test/decompiler/reference/jak2/engine/game/pilot-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/pilot-h_REF.gc @@ -43,7 +43,7 @@ (seat-index int8 :offset-assert 41) (backup-nav-radius float :offset-assert 44) (cam-side-shift float :offset-assert 48) - (enable-cam-side-shift basic :offset-assert 52) + (enable-cam-side-shift symbol :offset-assert 52) (gun? symbol :offset-assert 56) (controls vehicle-controls :inline :offset-assert 60) (accel-array vector 8 :inline :offset-assert 80) diff --git a/test/decompiler/reference/jak2/engine/level/bsp-h_REF.gc b/test/decompiler/reference/jak2/engine/level/bsp-h_REF.gc index cd53b37ed7..f8344cfbf1 100644 --- a/test/decompiler/reference/jak2/engine/level/bsp-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/level/bsp-h_REF.gc @@ -71,7 +71,7 @@ (region-array region-array :offset-assert 192) (collide-hash collide-hash :offset-assert 196) (wind-array-length int32 :offset 204) - (bsp-header-jkh1b23 clock :offset 208) + (city-level-info city-level-info :offset 208) (vis-spheres vector-array :offset 216) (region-tree drawable-tree-region-prim :offset 252) (tfrag-masks texture-masks-array :offset-assert 256) diff --git a/test/decompiler/reference/jak2/engine/level/level_REF.gc b/test/decompiler/reference/jak2/engine/level/level_REF.gc index 8fe49ea4e0..abc6c983e9 100644 --- a/test/decompiler/reference/jak2/engine/level/level_REF.gc +++ b/test/decompiler/reference/jak2/engine/level/level_REF.gc @@ -1145,7 +1145,7 @@ ) ) ) - (if (and (!= (-> obj bsp bsp-header-jkh1b23) 0) *traffic-manager*) + (if (and (!= (-> obj bsp city-level-info) 0) *traffic-manager*) (send-event *traffic-manager* 'level-loaded obj) ) (when (-> obj info activate-func) @@ -1173,7 +1173,7 @@ (case (-> obj status) (('active 'alive) (format 0 "----------- kill ~A (status ~A)~%" obj (-> obj status)) - (if (and (!= (-> obj bsp bsp-header-jkh1b23) 0) *traffic-manager*) + (if (and (!= (-> obj bsp city-level-info) 0) *traffic-manager*) (send-event *traffic-manager* 'level-killed obj) ) (when (-> obj info kill-func) diff --git a/test/decompiler/reference/jak2/engine/physics/rigid-body-h_REF.gc b/test/decompiler/reference/jak2/engine/physics/rigid-body-h_REF.gc index 76a31450a6..52028bdf65 100644 --- a/test/decompiler/reference/jak2/engine/physics/rigid-body-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/physics/rigid-body-h_REF.gc @@ -464,12 +464,12 @@ (active () _type_ :state 28) (rigid-body-object-method-29 (_type_ float) none 29) (rigid-body-object-method-30 (_type_) none 30) - (rigid-body-object-method-31 (_type_ rigid-body-object-constants) none 31) - (rigid-body-object-method-32 (_type_) none 32) - (rigid-body-object-method-33 (_type_) none 33) + (alloc-and-init-rigid-body-control (_type_ rigid-body-object-constants) none 31) + (allocate-and-init-cshape (_type_) none 32) + (init-skel-and-rigid-body (_type_) none 33) (rigid-body-object-method-34 (_type_) none 34) (rigid-body-object-method-35 (_type_) none 35) - (rigid-body-object-method-36 (_type_) none 36) + (do-engine-sounds (_type_) none 36) (rigid-body-object-method-37 (_type_) none 37) (rigid-body-object-method-38 (_type_) none 38) (rigid-body-object-method-39 (_type_) none 39) diff --git a/test/decompiler/reference/jak2/engine/physics/rigid-body_REF.gc b/test/decompiler/reference/jak2/engine/physics/rigid-body_REF.gc index 583569756b..6ade864f55 100644 --- a/test/decompiler/reference/jak2/engine/physics/rigid-body_REF.gc +++ b/test/decompiler/reference/jak2/engine/physics/rigid-body_REF.gc @@ -1001,7 +1001,7 @@ ;; definition for method 31 of type rigid-body-object ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-31 rigid-body-object ((obj rigid-body-object) (arg0 rigid-body-object-constants)) +(defmethod alloc-and-init-rigid-body-control rigid-body-object ((obj rigid-body-object) (arg0 rigid-body-object-constants)) (set! (-> obj info) arg0) (set! (-> obj rbody) (new 'process 'rigid-body-control obj)) (update-transforms (-> obj root-override-2)) @@ -1025,7 +1025,7 @@ ;; definition for method 32 of type rigid-body-object ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-32 rigid-body-object ((obj rigid-body-object)) +(defmethod allocate-and-init-cshape rigid-body-object ((obj rigid-body-object)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -1077,8 +1077,8 @@ ;; definition for method 33 of type rigid-body-object ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-33 rigid-body-object ((obj rigid-body-object)) - (rigid-body-object-method-31 obj *rigid-body-object-constants*) +(defmethod init-skel-and-rigid-body rigid-body-object ((obj rigid-body-object)) + (alloc-and-init-rigid-body-control obj *rigid-body-object-constants*) 0 (none) ) @@ -1092,9 +1092,9 @@ This commonly includes things such as: - collision information - loading the skeleton group / bones - sounds" - (rigid-body-object-method-32 obj) + (allocate-and-init-cshape obj) (process-drawable-from-entity! obj arg0) - (rigid-body-object-method-33 obj) + (init-skel-and-rigid-body obj) (rigid-body-object-method-34 obj) 0 (none) @@ -1102,7 +1102,7 @@ This commonly includes things such as: ;; definition for method 36 of type rigid-body-object ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-36 rigid-body-object ((obj rigid-body-object)) +(defmethod do-engine-sounds rigid-body-object ((obj rigid-body-object)) 0 (none) ) @@ -1111,7 +1111,7 @@ This commonly includes things such as: ;; WARN: Return type mismatch int vs none. (defmethod rigid-body-object-method-37 rigid-body-object ((obj rigid-body-object)) (rigid-body-object-method-30 obj) - (rigid-body-object-method-36 obj) + (do-engine-sounds obj) (let ((v1-4 (-> obj rbody)) (a1-0 (-> obj root-override-2)) ) diff --git a/test/decompiler/reference/jak2/engine/target/target-h_REF.gc b/test/decompiler/reference/jak2/engine/target/target-h_REF.gc index d6cfbea715..928605c621 100644 --- a/test/decompiler/reference/jak2/engine/target/target-h_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/target-h_REF.gc @@ -186,8 +186,16 @@ target-mech-stance (target-mech-start handle float symbol) target-mech-walk - target-pilot-edge-grab - (target-pilot-start handle) + (target-pilot-clone-anim handle) + (target-pilot-death symbol) + (target-pilot-edge-grab pilot-edge-grab-info) + target-pilot-get-off + target-pilot-get-on + target-pilot-grab + (target-pilot-hit symbol attack-info) + target-pilot-impact + target-pilot-stance + (target-pilot-start handle symbol symbol) (target-play-anim string handle) (target-pole-cycle handle) (target-pole-flip-forward float float float) diff --git a/test/decompiler/reference/jak2/engine/target/target-handler_REF.gc b/test/decompiler/reference/jak2/engine/target/target-handler_REF.gc index f4c89a52e9..77438969b1 100644 --- a/test/decompiler/reference/jak2/engine/target/target-handler_REF.gc +++ b/test/decompiler/reference/jak2/engine/target/target-handler_REF.gc @@ -1225,17 +1225,14 @@ ) ) (when s5-1 - (case (-> arg3 param 0) - (('pilot-daxter 'pilot-race-daxter) - #t - ) - (else - ) - ) - enter-state - (let ((a0-93 (process->handle s5-1))) - (-> arg3 param 3) - (go target-pilot-start (the-as handle a0-93)) + (let* ((v1-83 (-> arg3 param 0)) + (a2-4 (if (or (= v1-83 'pilot-daxter) (= v1-83 'pilot-race-daxter)) + #t + #f + ) + ) + ) + (go target-pilot-start (process->handle s5-1) (the-as symbol (-> arg3 param 3)) a2-4) ) ) ) @@ -1362,9 +1359,7 @@ (label cfg-238) (b! (!= v1-0 'pilot-edge-grab) cfg-242 :delay (nop!)) (b! (logtest? (-> self focus-status) (focus-status dead hit grabbed)) cfg-241 :delay (set! v0-0 #f)) - enter-state - (-> arg3 param 0) - (set! v0-0 (go target-pilot-edge-grab)) + (set! v0-0 (go target-pilot-edge-grab (the-as pilot-edge-grab-info (-> arg3 param 0)))) (label cfg-241) (b! #t cfg-291 :delay (nop!)) (label cfg-242) diff --git a/test/decompiler/reference/jak2/levels/city/common/bike_REF.gc b/test/decompiler/reference/jak2/levels/city/common/bike_REF.gc new file mode 100644 index 0000000000..81eeb27227 --- /dev/null +++ b/test/decompiler/reference/jak2/levels/city/common/bike_REF.gc @@ -0,0 +1,1689 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +(defskelgroup skel-bikea bikea bikea-lod0-jg bikea-idle-ja + ((bikea-lod0-mg (meters 20)) (bikea-lod1-mg (meters 40)) (bikea-lod2-mg (meters 999999))) + :bounds (static-spherem 0 0 0 3.4) + :shadow bikea-shadow-mg + :origin-joint-index 3 + ) + +;; failed to figure out what this is: +(defskelgroup skel-bikeb bikeb bikeb-lod0-jg bikeb-idle-ja + ((bikeb-lod0-mg (meters 20)) (bikeb-lod1-mg (meters 40)) (bikeb-lod2-mg (meters 999999))) + :bounds (static-spherem 0 0 0 3.4) + :shadow bikeb-shadow-mg + :origin-joint-index 3 + ) + +;; failed to figure out what this is: +(defskelgroup skel-bikec bikec bikec-lod0-jg bikec-idle-ja + ((bikec-lod0-mg (meters 20)) (bikec-lod1-mg (meters 40)) (bikec-lod2-mg (meters 999999))) + :bounds (static-spherem 0 0 0 3.8) + :shadow bikec-shadow-mg + :origin-joint-index 3 + ) + +;; failed to figure out what this is: +(defskelgroup skel-guard-bike crimson-bike crimson-bike-lod0-jg crimson-bike-idle-ja + ((crimson-bike-lod0-mg (meters 20)) (crimson-bike-lod1-mg (meters 40)) (crimson-bike-lod2-mg (meters 999999))) + :bounds (static-spherem 0 0 0 3.4) + :shadow crimson-bike-shadow-mg + ) + +;; definition for symbol *bike-explosion-info*, type vehicle-explosion-info +(define *bike-explosion-info* + (new 'static 'vehicle-explosion-info + :joints (new 'static 'boxed-array :type joint-exploder-static-joint-params + (new 'static 'joint-exploder-static-joint-params :joint-index 3 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 4 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 5 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 6 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 7 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 8 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 9 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 10 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 11 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 12 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 13 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 14 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 15 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 16 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 17 :parent-joint-index -1) + (new 'static 'joint-exploder-static-joint-params :joint-index 18 :parent-joint-index -1) + ) + :collide-spec #x1 + :art-level 'ctywide + :skel #f + :skel-name "skel-vehicle-explosion" + :anim 2 + ) + ) + +;; definition for symbol *bikea-constants*, type rigid-body-vehicle-constants +(define *bikea-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 2.0 + :inv-mass 0.5 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :z 2457.6 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 3) (meters 4) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*bikea-constants* + :flags #x70 + :object-type #xb + :guard-type #x7 + :max-engine-thrust (meters 50) + :inv-max-engine-thrust 0.0000048828124 + :engine-response-rate 60.0 + :engine-intake-factor 1.5 + :brake-factor 3.5 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.3 + :air-drag-factor 1.0 + :steering-thruster-factor 5.0 + :steering-thruster-max-gain 4.0 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.5 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.75 + :pitch-control-factor 1.0 + :roll-control-factor 1.0 + :jump-thrust-factor 0.625 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 4) + :turning-accel (meters 25) + :toughness-factor 1.0 + :damage-factor 4.0 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 5461.3335 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 2 + :section-count 2 + :grab-rail-count 2 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 2 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x 2048.0 :z 4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -2048.0 :z 4096.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info :position (new 'static 'vector :w (the-as float #x10000))) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 2048.0 :z -4096.0 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 409.6 :z 4710.4 :w 1.0) + (new 'static 'vector :x -2457.6 :y 409.6 :z 4710.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x10 #x8 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x20 #x4 #x0) + :damage-seg-count 2 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-offset -0.25 + :engine-pitch-mod-amp 0.05 + :engine-sound-select 1 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "bike-scrape-stn") + :glance-sound (static-sound-name "bike-glance-stn") + :impact-sound (static-sound-name "bike-impact-stn") + :extra-sound (static-sound-name "bike-by-1") + :explosion-part #xa1 + :headlight-count 1 + :taillight-count 1 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :z -3276.8 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :y 204.8 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :y 204.8 :z -3276.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1638.4 :y -2048.0 :z 7372.8 :w 1.0) + (new 'static 'vector :x -1638.4 :y -2048.0 :z 7372.8 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 (new 'static 'vector :w 1.0) (new 'static 'vector :w 1.0)) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :y -819.2 :z 10240.0 :w 1.0) + (new 'static 'vector) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 (new 'static 'vector :y 1433.6 :z -10240.0 :w 1.0) (new 'static 'vector)) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z 7372.8003 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z -2457.6 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10240.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5324.8 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10649.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :brake-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :color-option-count 3 + :color-option-array (new 'static 'inline-array vector 3 + (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 0.7 :w 1.0) + ) + ) + ) + +;; definition for symbol *bikeb-constants*, type rigid-body-vehicle-constants +(define *bikeb-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 2.0 + :inv-mass 0.5 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :z 2457.6 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 3) (meters 4) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*bikeb-constants* + :flags #x70 + :object-type #xc + :guard-type #x7 + :max-engine-thrust (meters 50) + :inv-max-engine-thrust 0.0000048828124 + :engine-response-rate 60.0 + :engine-intake-factor 1.5 + :brake-factor 3.5 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.3 + :air-drag-factor 1.0 + :steering-thruster-factor 5.0 + :steering-thruster-max-gain 4.0 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.5 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.75 + :pitch-control-factor 1.0 + :roll-control-factor 1.0 + :jump-thrust-factor 0.625 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 4) + :turning-accel (meters 25) + :toughness-factor 1.0 + :damage-factor 4.0 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 5461.3335 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 2 + :section-count 2 + :grab-rail-count 2 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 2 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x 2048.0 :z 4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -2048.0 :z 4096.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 757.76 :z 1175.552 :w (the-as float #x10000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 2048.0 :z -4096.0 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 409.6 :z 4710.4 :w 1.0) + (new 'static 'vector :x -2457.6 :y 409.6 :z 4710.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x20 #x8 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x40 #x10 #x4) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-offset -0.25 + :engine-pitch-mod-amp 0.05 + :engine-sound-select 1 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "bike-scrape-stn") + :glance-sound (static-sound-name "bike-glance-stn") + :impact-sound (static-sound-name "bike-impact-stn") + :extra-sound (static-sound-name "bike-by-1") + :explosion-part #xa1 + :headlight-count 1 + :taillight-count 1 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :z -3276.8 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :y 204.8 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :y 204.8 :z -3276.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1638.4 :y -2048.0 :z 7372.8 :w 1.0) + (new 'static 'vector :x -1638.4 :y -2048.0 :z 7372.8 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 (new 'static 'vector :w 1.0) (new 'static 'vector :w 1.0)) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :z 11059.2 :w 1.0) + (new 'static 'vector) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 (new 'static 'vector :y 1433.6 :z -8192.0 :w 1.0) (new 'static 'vector)) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 7372.8003 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -2457.6 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10240.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5324.8 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10649.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :brake-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :color-option-count 3 + :color-option-array (new 'static 'inline-array vector 3 + (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 0.7 :w 1.0) + ) + ) + ) + +;; definition for symbol *bikec-constants*, type rigid-body-vehicle-constants +(define *bikec-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 2.0 + :inv-mass 0.5 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :z 2457.6 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 3) (meters 4) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*bikec-constants* + :flags #x70 + :object-type #xd + :guard-type #x7 + :max-engine-thrust (meters 50) + :inv-max-engine-thrust 0.0000048828124 + :engine-response-rate 60.0 + :engine-intake-factor 1.5 + :brake-factor 3.5 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.3 + :air-drag-factor 1.0 + :steering-thruster-factor 5.0 + :steering-thruster-max-gain 4.0 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.5 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.75 + :pitch-control-factor 1.0 + :roll-control-factor 1.0 + :jump-thrust-factor 0.625 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 4) + :turning-accel (meters 25) + :toughness-factor 1.0 + :damage-factor 4.0 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 3640.889 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 2 + :section-count 2 + :grab-rail-count 2 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 2 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x 2048.0 :z 8192.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -2048.0 :z 8192.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 802.816 :z 1318.912 :w (the-as float #x10000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 2048.0 :z -4096.0 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 409.6 :z 4710.4 :w 1.0) + (new 'static 'vector :x -2457.6 :y 409.6 :z 4710.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x20 #x8 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x40 #x10 #x4) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-offset -0.25 + :engine-pitch-mod-amp 0.05 + :engine-sound-select 1 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "bike-scrape-stn") + :glance-sound (static-sound-name "bike-glance-stn") + :impact-sound (static-sound-name "bike-impact-stn") + :extra-sound (static-sound-name "bike-by-1") + :explosion-part #xa1 + :headlight-count 1 + :taillight-count 1 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :z -3276.8 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :y 204.8 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :y 204.8 :z -3276.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1638.4 :y -2048.0 :z 7372.8 :w 1.0) + (new 'static 'vector :x -1638.4 :y -2048.0 :z 7372.8 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 (new 'static 'vector :w 1.0) (new 'static 'vector :w 1.0)) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :y -614.4 :z 13721.6 :w 1.0) + (new 'static 'vector) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 (new 'static 'vector :y 614.4 :z -7168.0 :w 1.0) (new 'static 'vector)) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 7372.8003 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -2457.6 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10240.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5324.8 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10649.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :brake-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :color-option-count 3 + :color-option-array (new 'static 'inline-array vector 3 + (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 1.0 :w 1.0) + (new 'static 'vector :x 1.0 :y 0.7 :z 0.7 :w 1.0) + ) + ) + ) + +;; definition for symbol *guard-bike-constants*, type rigid-body-vehicle-constants +(define *guard-bike-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 2.0 + :inv-mass 0.5 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :z 2457.6 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 3) (meters 4) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*guard-bike-constants* + :flags #x54 + :object-type #x12 + :guard-type #x4 + :max-engine-thrust (meters 50) + :inv-max-engine-thrust 0.0000048828124 + :engine-response-rate 60.0 + :engine-intake-factor 1.5 + :brake-factor 3.5 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.3 + :air-drag-factor 1.0 + :steering-thruster-factor 5.0 + :steering-thruster-max-gain 4.0 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.5 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000034877234 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.75 + :pitch-control-factor 1.0 + :roll-control-factor 1.0 + :jump-thrust-factor 0.625 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 4) + :turning-accel (meters 25) + :toughness-factor 1.0 + :damage-factor 4.0 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 5461.3335 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 2 + :section-count 2 + :grab-rail-count 2 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 2 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x 2048.0 :z 4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -2048.0 :z 4096.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info :position (new 'static 'vector :w (the-as float #x10000))) + (new 'static 'vehicle-seat-info :position (new 'static 'vector :z -4096.0 :w (the-as float #x40000))) + (new 'static 'vehicle-seat-info) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 409.6 :z 4710.4 :w 1.0) + (new 'static 'vector :x -2457.6 :y 409.6 :z 4710.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x20 #x8 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x40 #x10 #x4) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-offset -0.25 + :engine-pitch-mod-amp 0.05 + :engine-sound-select 1 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "bike-scrape-stn") + :glance-sound (static-sound-name "bike-glance-stn") + :impact-sound (static-sound-name "bike-impact-stn") + :extra-sound (static-sound-name "bike-by-1") + :explosion-part #xa1 + :headlight-count 1 + :taillight-count 1 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :z -11878.4 :w 1.0) + (new 'static 'vector :x -1024.0 :z -11878.4 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :y 204.8 :z -3276.8 :w 1.0) + (new 'static 'vector :x -2048.0 :y 204.8 :z -3276.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 + (new 'static 'vector :x 0.7 :z -0.7 :w 1.0) + (new 'static 'vector :x -0.7 :z -0.7 :w 1.0) + ) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :y 204.8 :z -4505.6 :w 1.0) + (new 'static 'vector :x -2048.0 :y 204.8 :z -4505.6 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :y 819.2 :z 12288.0 :w 1.0) + (new 'static 'vector) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 (new 'static 'vector :y 2867.2 :z -9420.8 :w 1.0) (new 'static 'vector)) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 7372.8003 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -2457.6 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10240.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5324.8 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10649.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :brake-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :color-option-count 1 + :color-option-array (new 'static 'inline-array vector 1 (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0)) + ) + ) + +;; failed to figure out what this is: +(set! (-> *bikea-constants* explosion) *bike-explosion-info*) + +;; failed to figure out what this is: +(set! (-> *bikeb-constants* explosion) *bike-explosion-info*) + +;; failed to figure out what this is: +(set! (-> *bikec-constants* explosion) *bike-explosion-info*) + +;; failed to figure out what this is: +(set! (-> *guard-bike-constants* explosion) *bike-explosion-info*) + +;; definition of type bike-base +(deftype bike-base (vehicle) + () + :heap-base #x2f0 + :method-count-assert 144 + :size-assert #x370 + :flag-assert #x9002f00370 + ) + +;; definition for method 3 of type bike-base +(defmethod inspect bike-base ((obj bike-base)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type vehicle inspect))) + (t9-0 obj) + ) + (label cfg-4) + obj + ) + +;; definition for method 36 of type bike-base +;; WARN: Return type mismatch int vs none. +(defmethod do-engine-sounds bike-base ((obj bike-base)) + ((the-as (function object none) (find-parent-method bike-base 36)) obj) + (when (logtest? (-> obj flags) (rigid-body-object-flag player-driving)) + (if (zero? (-> obj roll-sound-id)) + (set! (-> obj roll-sound-id) (new-sound-id)) + ) + (let* ((f0-4 + (* 4.0 + (-> obj force-scale) + (-> obj sputter-sound-envelope) + (-> obj info-override inv-max-engine-thrust) + (+ (-> obj roll-thrust 0) (-> obj roll-thrust 1)) + ) + ) + (f1-6 (* 0.32 f0-4)) + (f0-5 0.5) + ) + (sound-play-by-name + (static-sound-name "bike-thrust") + (-> obj roll-sound-id) + (the int (* 1024.0 f1-6)) + (the int (* 1524.0 f0-5)) + 0 + (sound-group sfx) + #t + ) + ) + ) + 0 + (none) + ) + +;; definition for method 85 of type bike-base +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod draw-thrusters bike-base ((obj bike-base)) + ((the-as (function object none) (find-parent-method bike-base 85)) obj) + (when (logtest? (-> obj rbody state flags) (rigid-body-flag enable-physics)) + (let ((s5-0 (new 'stack-no-clear 'inline-array 'matrix 3))) + (let* ((v1-4 (the-as object (-> s5-0 0 vector 2))) + (a3-0 (-> obj node-list data 0 bone transform)) + (a0-5 (-> a3-0 quad 0)) + (a1-1 (-> a3-0 quad 1)) + (a2-0 (-> a3-0 quad 2)) + (a3-1 (-> a3-0 trans quad)) + ) + (set! (-> (the-as vector v1-4) quad) a0-5) + (set! (-> (the-as (pointer uint128) v1-4) 1) a1-1) + (set! (-> (the-as (pointer uint128) v1-4) 2) a2-0) + (set! (-> (the-as (pointer uint128) v1-4) 3) a3-1) + ) + (set-vector! (-> s5-0 0 vector 1) 0.0 -1.0 0.0 1.0) + (vector-rotate*! (-> s5-0 0 vector 1) (-> s5-0 0 vector 1) (the-as matrix (-> s5-0 0 vector 2))) + (let ((s4-0 (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :y -1228.8 :z 2457.6 :w 1.0) + (new 'static 'vector :x -2048.0 :y -1228.8 :z 2457.6 :w 1.0) + ) + ) + (s3-0 (new 'static 'inline-array vector 2 + (new 'static 'vector :x 0.707 :y -0.707 :w 1.0) + (new 'static 'vector :x -0.707 :y -0.707 :w 1.0) + ) + ) + ) + (dotimes (s2-0 2) + (when (< 0.0 (-> obj roll-thrust s2-0)) + (vector-rotate*! (-> s5-0 0 vector 1) (-> s3-0 s2-0) (the-as matrix (-> s5-0 0 vector 2))) + (vector-matrix*! (the-as vector (-> s5-0 0)) (-> s4-0 s2-0) (the-as matrix (-> s5-0 0 vector 2))) + (let* ((a0-11 obj) + (t9-5 (method-of-object a0-11 draw-thruster)) + (a1-5 (-> s5-0 0)) + (a2-4 (-> s5-0 0 vector 1)) + (a3-2 1638.4) + (f0-5 12288.0) + (f1-1 (-> obj info-override extra gravity)) + ) + (t9-5 + a0-11 + (the-as vector a1-5) + a2-4 + a3-2 + (* f0-5 (/ 1.0 f1-1) (-> obj info-override info inv-mass) (-> obj force-scale) (-> obj roll-thrust s2-0)) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition of type bikea +(deftype bikea (bike-base) + ((fin-fl joint-mod-rotate-local :offset-assert 880) + (fin-fr joint-mod-rotate-local :offset-assert 884) + (fin-rl joint-mod-rotate-local :offset-assert 888) + (fin-rr joint-mod-rotate-local :offset-assert 892) + (rudder joint-mod-rotate-local :offset-assert 896) + (brake-l joint-mod-rotate-local :offset-assert 900) + (brake-r joint-mod-rotate-local :offset-assert 904) + ) + :heap-base #x310 + :method-count-assert 144 + :size-assert #x38c + :flag-assert #x900310038c + ) + +;; definition for method 3 of type bikea +(defmethod inspect bikea ((obj bikea)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type bike-base inspect))) + (t9-0 obj) + ) + (format #t "~2Tfin-fl: ~A~%" (-> obj fin-fl)) + (format #t "~2Tfin-fr: ~A~%" (-> obj fin-fr)) + (format #t "~2Tfin-rl: ~A~%" (-> obj fin-rl)) + (format #t "~2Tfin-rr: ~A~%" (-> obj fin-rr)) + (format #t "~2Trudder: ~A~%" (-> obj rudder)) + (format #t "~2Tbrake-l: ~A~%" (-> obj brake-l)) + (format #t "~2Tbrake-r: ~A~%" (-> obj brake-r)) + (label cfg-4) + obj + ) + +;; definition for method 7 of type bikea +(defmethod relocate bikea ((obj bikea) (arg0 int)) + (if (nonzero? (-> obj fin-fl)) + (&+! (-> obj fin-fl) arg0) + ) + (if (nonzero? (-> obj fin-fr)) + (&+! (-> obj fin-fr) arg0) + ) + (if (nonzero? (-> obj fin-rl)) + (&+! (-> obj fin-rl) arg0) + ) + (if (nonzero? (-> obj fin-rr)) + (&+! (-> obj fin-rr) arg0) + ) + (if (nonzero? (-> obj rudder)) + (&+! (-> obj rudder) arg0) + ) + (if (nonzero? (-> obj brake-l)) + (&+! (-> obj brake-l) arg0) + ) + (if (nonzero? (-> obj brake-r)) + (&+! (-> obj brake-r) arg0) + ) + ((the-as (function object int bikea) (find-parent-method bikea 7)) obj arg0) + ) + +;; definition for method 32 of type bikea +;; WARN: Return type mismatch int vs none. +(defmethod allocate-and-init-cshape bikea ((obj bikea)) + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-default) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate vehicle)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 5) 0))) + (set! (-> s5-0 total-prims) (the-as uint 6)) + (set! (-> s4-0 prim-core action) (collide-action solid)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 11264.0) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-11 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-11 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-11 transform-index) 0) + (set-vector! (-> v1-11 local-sphere) 0.0 -819.2 4505.6 3686.4) + (set! (-> v1-11 nav-radius) 6144.0) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-13 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-13 transform-index) 0) + (set-vector! (-> v1-13 local-sphere) 0.0 0.0 -3686.4 4096.0) + (set! (-> v1-13 nav-radius) 6144.0) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 96)))) + (set! (-> v1-15 prim-core action) (collide-action solid)) + (set! (-> v1-15 transform-index) 0) + (set-vector! (-> v1-15 local-sphere) 204.8 3276.8 1228.8 3276.8) + ) + (let ((v1-17 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-17 prim-core action) (collide-action solid)) + (set! (-> v1-17 transform-index) 0) + (set-vector! (-> v1-17 local-sphere) 0.0 -819.2 9011.2 1638.4) + ) + (let ((v1-19 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-19 prim-core action) (collide-action solid)) + (set! (-> v1-19 transform-index) 0) + (set-vector! (-> v1-19 local-sphere) 0.0 1228.8 -8601.6 2048.0) + ) + (set! (-> s5-0 nav-radius) 16384.0) + (let ((v1-21 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-21 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-21 prim-core collide-with)) + ) + (set! (-> s5-0 nav-flags) (nav-flags has-child-spheres)) + (set! (-> obj root-override-2) s5-0) + ) + 0 + (none) + ) + +;; definition for method 86 of type bikea +;; WARN: Return type mismatch int vs none. +(defmethod update-joint-mods bikea ((obj bikea)) + (let ((f30-0 (* 5461.3335 (-> obj controls steering))) + (f26-0 (* -5461.3335 (-> obj controls lean-z))) + (f28-0 (* -13653.333 (-> obj controls brake))) + (s5-0 (new 'static 'vector :x 1.0 :w 1.0)) + ) + (quaternion-vector-angle! (-> obj fin-rl rotation) s5-0 (+ f26-0 (* 0.2 f30-0))) + (quaternion-vector-angle! (-> obj fin-rr rotation) s5-0 (+ (- f26-0) (* 0.2 f30-0))) + (quaternion-vector-angle! (-> obj fin-fl rotation) s5-0 (- (* -0.2 f26-0) f30-0)) + (quaternion-vector-angle! (-> obj fin-fr rotation) s5-0 (- (* 0.2 f26-0) f30-0)) + (quaternion-vector-angle! (-> obj rudder rotation) s5-0 f30-0) + (quaternion-vector-angle! (-> obj brake-l rotation) s5-0 f28-0) + (quaternion-vector-angle! (-> obj brake-r rotation) s5-0 f28-0) + ) + 0 + (none) + ) + +;; definition for method 33 of type bikea +;; WARN: Return type mismatch int vs none. +(defmethod init-skel-and-rigid-body bikea ((obj bikea)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-bikea" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *bikea-constants*) + (set! (-> obj fin-fl) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj fin-fr) (new 'process 'joint-mod-rotate-local obj 7 #t)) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj rudder) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj brake-l) (new 'process 'joint-mod-rotate-local obj 9 #t)) + (set! (-> obj brake-r) (new 'process 'joint-mod-rotate-local obj 10 #t)) + 0 + (none) + ) + +;; definition of type bikeb +(deftype bikeb (bike-base) + ((fin-rl joint-mod-rotate-local :offset-assert 880) + (fin-rr joint-mod-rotate-local :offset-assert 884) + (rudder joint-mod-rotate-local :offset-assert 888) + (rudder-f joint-mod-rotate-local :offset-assert 892) + (brake-l joint-mod-rotate-local :offset-assert 896) + (brake-r joint-mod-rotate-local :offset-assert 900) + (flap-l joint-mod-rotate-local :offset-assert 904) + (flap-r joint-mod-rotate-local :offset-assert 908) + ) + :heap-base #x310 + :method-count-assert 144 + :size-assert #x390 + :flag-assert #x9003100390 + ) + +;; definition for method 3 of type bikeb +(defmethod inspect bikeb ((obj bikeb)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type bike-base inspect))) + (t9-0 obj) + ) + (format #t "~2Tfin-rl: ~A~%" (-> obj fin-rl)) + (format #t "~2Tfin-rr: ~A~%" (-> obj fin-rr)) + (format #t "~2Trudder: ~A~%" (-> obj rudder)) + (format #t "~2Trudder-f: ~A~%" (-> obj rudder-f)) + (format #t "~2Tbrake-l: ~A~%" (-> obj brake-l)) + (format #t "~2Tbrake-r: ~A~%" (-> obj brake-r)) + (format #t "~2Tflap-l: ~A~%" (-> obj flap-l)) + (format #t "~2Tflap-r: ~A~%" (-> obj flap-r)) + (label cfg-4) + obj + ) + +;; definition for method 7 of type bikeb +(defmethod relocate bikeb ((obj bikeb) (arg0 int)) + (if (nonzero? (-> obj fin-rl)) + (&+! (-> obj fin-rl) arg0) + ) + (if (nonzero? (-> obj fin-rr)) + (&+! (-> obj fin-rr) arg0) + ) + (if (nonzero? (-> obj rudder)) + (&+! (-> obj rudder) arg0) + ) + (if (nonzero? (-> obj rudder-f)) + (&+! (-> obj rudder-f) arg0) + ) + (if (nonzero? (-> obj brake-l)) + (&+! (-> obj brake-l) arg0) + ) + (if (nonzero? (-> obj brake-r)) + (&+! (-> obj brake-r) arg0) + ) + (if (nonzero? (-> obj flap-l)) + (&+! (-> obj flap-l) arg0) + ) + (if (nonzero? (-> obj flap-r)) + (&+! (-> obj flap-r) arg0) + ) + ((the-as (function object int bikeb) (find-parent-method bikeb 7)) obj arg0) + ) + +;; definition for method 32 of type bikeb +;; WARN: Return type mismatch int vs none. +(defmethod allocate-and-init-cshape bikeb ((obj bikeb)) + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-default) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate vehicle)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 5) 0))) + (set! (-> s5-0 total-prims) (the-as uint 6)) + (set! (-> s4-0 prim-core action) (collide-action solid)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 11264.0) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-11 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-11 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-11 transform-index) 0) + (set-vector! (-> v1-11 local-sphere) 0.0 -409.6 4505.6 4300.8) + (set! (-> v1-11 nav-radius) 6144.0) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-13 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-13 transform-index) 0) + (set-vector! (-> v1-13 local-sphere) 0.0 0.0 -3686.4 4096.0) + (set! (-> v1-13 nav-radius) 6144.0) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 96)))) + (set! (-> v1-15 prim-core action) (collide-action solid)) + (set! (-> v1-15 transform-index) 0) + (set-vector! (-> v1-15 local-sphere) 204.8 3276.8 1228.8 3276.8) + ) + (let ((v1-17 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-17 prim-core action) (collide-action solid)) + (set! (-> v1-17 transform-index) 0) + (set-vector! (-> v1-17 local-sphere) 0.0 -819.2 9011.2 1638.4) + ) + (let ((v1-19 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-19 prim-core action) (collide-action solid)) + (set! (-> v1-19 transform-index) 0) + (set-vector! (-> v1-19 local-sphere) 0.0 1228.8 -8601.6 2048.0) + ) + (set! (-> s5-0 nav-radius) 16384.0) + (let ((v1-21 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-21 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-21 prim-core collide-with)) + ) + (set! (-> s5-0 nav-flags) (nav-flags has-child-spheres)) + (set! (-> obj root-override-2) s5-0) + ) + 0 + (none) + ) + +;; definition for method 86 of type bikeb +;; WARN: Return type mismatch int vs none. +(defmethod update-joint-mods bikeb ((obj bikeb)) + (let ((f30-0 (* 5461.3335 (-> obj controls steering))) + (f26-0 (* -5461.3335 (-> obj controls lean-z))) + (f28-0 (* 13653.333 (-> obj controls brake))) + (s5-0 (new 'static 'vector :x 1.0 :w 1.0)) + ) + (quaternion-vector-angle! (-> obj fin-rl rotation) s5-0 (+ f26-0 (* 0.2 f30-0))) + (quaternion-vector-angle! (-> obj fin-rr rotation) s5-0 (+ (- f26-0) (* 0.2 f30-0))) + (quaternion-vector-angle! (-> obj rudder rotation) s5-0 f30-0) + (quaternion-vector-angle! (-> obj rudder-f rotation) s5-0 (- f30-0)) + (quaternion-vector-angle! (-> obj brake-l rotation) s5-0 (- f28-0)) + (quaternion-vector-angle! (-> obj brake-r rotation) s5-0 f28-0) + (quaternion-vector-angle! (-> obj flap-l rotation) s5-0 f28-0) + (quaternion-vector-angle! (-> obj flap-r rotation) s5-0 (- f28-0)) + ) + 0 + (none) + ) + +;; definition for method 33 of type bikeb +;; WARN: Return type mismatch int vs none. +(defmethod init-skel-and-rigid-body bikeb ((obj bikeb)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-bikeb" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *bikeb-constants*) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 10 #t)) + (set! (-> obj rudder) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj rudder-f) (new 'process 'joint-mod-rotate-local obj 7 #t)) + (set! (-> obj brake-l) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj brake-r) (new 'process 'joint-mod-rotate-local obj 9 #t)) + (set! (-> obj flap-l) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj flap-r) (new 'process 'joint-mod-rotate-local obj 11 #t)) + 0 + (none) + ) + +;; definition of type bikec +(deftype bikec (bike-base) + ((fin-fl joint-mod-rotate-local :offset-assert 880) + (fin-fr joint-mod-rotate-local :offset-assert 884) + (fin-rl joint-mod-rotate-local :offset-assert 888) + (fin-rr joint-mod-rotate-local :offset-assert 892) + (fin2-fl joint-mod-rotate-local :offset-assert 896) + (fin2-fr joint-mod-rotate-local :offset-assert 900) + (rudder joint-mod-rotate-local :offset-assert 904) + (brake-l joint-mod-rotate-local :offset-assert 908) + (brake-r joint-mod-rotate-local :offset-assert 912) + (spoiler-l joint-mod-rotate-local :offset-assert 916) + (spoiler-r joint-mod-rotate-local :offset-assert 920) + ) + :heap-base #x320 + :method-count-assert 144 + :size-assert #x39c + :flag-assert #x900320039c + ) + +;; definition for method 3 of type bikec +(defmethod inspect bikec ((obj bikec)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type bike-base inspect))) + (t9-0 obj) + ) + (format #t "~2Tfin-fl: ~A~%" (-> obj fin-fl)) + (format #t "~2Tfin-fr: ~A~%" (-> obj fin-fr)) + (format #t "~2Tfin-rl: ~A~%" (-> obj fin-rl)) + (format #t "~2Tfin-rr: ~A~%" (-> obj fin-rr)) + (format #t "~2Tfin2-fl: ~A~%" (-> obj fin2-fl)) + (format #t "~2Tfin2-fr: ~A~%" (-> obj fin2-fr)) + (format #t "~2Trudder: ~A~%" (-> obj rudder)) + (format #t "~2Tbrake-l: ~A~%" (-> obj brake-l)) + (format #t "~2Tbrake-r: ~A~%" (-> obj brake-r)) + (format #t "~2Tspoiler-l: ~A~%" (-> obj spoiler-l)) + (format #t "~2Tspoiler-r: ~A~%" (-> obj spoiler-r)) + (label cfg-4) + obj + ) + +;; definition for method 7 of type bikec +(defmethod relocate bikec ((obj bikec) (arg0 int)) + (if (nonzero? (-> obj fin-fl)) + (&+! (-> obj fin-fl) arg0) + ) + (if (nonzero? (-> obj fin-fr)) + (&+! (-> obj fin-fr) arg0) + ) + (if (nonzero? (-> obj fin-rl)) + (&+! (-> obj fin-rl) arg0) + ) + (if (nonzero? (-> obj fin-rr)) + (&+! (-> obj fin-rr) arg0) + ) + (if (nonzero? (-> obj fin2-fl)) + (&+! (-> obj fin2-fl) arg0) + ) + (if (nonzero? (-> obj fin2-fr)) + (&+! (-> obj fin2-fr) arg0) + ) + (if (nonzero? (-> obj rudder)) + (&+! (-> obj rudder) arg0) + ) + (if (nonzero? (-> obj brake-l)) + (&+! (-> obj brake-l) arg0) + ) + (if (nonzero? (-> obj brake-r)) + (&+! (-> obj brake-r) arg0) + ) + (if (nonzero? (-> obj spoiler-l)) + (&+! (-> obj spoiler-l) arg0) + ) + (if (nonzero? (-> obj spoiler-r)) + (&+! (-> obj spoiler-r) arg0) + ) + ((the-as (function object int bikec) (find-parent-method bikec 7)) obj arg0) + ) + +;; definition for method 32 of type bikec +;; WARN: Return type mismatch int vs none. +(defmethod allocate-and-init-cshape bikec ((obj bikec)) + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-default) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate vehicle)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 5) 0))) + (set! (-> s5-0 total-prims) (the-as uint 6)) + (set! (-> s4-0 prim-core action) (collide-action solid)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 13312.0) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-11 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-11 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-11 transform-index) 0) + (set-vector! (-> v1-11 local-sphere) 0.0 0.0 4505.6 4300.8) + (set! (-> v1-11 nav-radius) 7577.6) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-13 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-13 transform-index) 0) + (set-vector! (-> v1-13 local-sphere) 0.0 0.0 -3686.4 4096.0) + (set! (-> v1-13 nav-radius) 6144.0) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 96)))) + (set! (-> v1-15 prim-core action) (collide-action solid)) + (set! (-> v1-15 transform-index) 0) + (set-vector! (-> v1-15 local-sphere) 204.8 3276.8 1228.8 3276.8) + ) + (let ((v1-17 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-17 prim-core action) (collide-action solid)) + (set! (-> v1-17 transform-index) 0) + (set-vector! (-> v1-17 local-sphere) 0.0 0.0 9011.2 3686.4) + ) + (let ((v1-19 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-19 prim-core action) (collide-action solid)) + (set! (-> v1-19 transform-index) 0) + (set-vector! (-> v1-19 local-sphere) 0.0 1228.8 -8601.6 2048.0) + ) + (set! (-> s5-0 nav-radius) 16384.0) + (let ((v1-21 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-21 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-21 prim-core collide-with)) + ) + (set! (-> s5-0 nav-flags) (nav-flags has-child-spheres)) + (set! (-> obj root-override-2) s5-0) + ) + 0 + (none) + ) + +;; definition for method 86 of type bikec +;; WARN: Return type mismatch int vs none. +(defmethod update-joint-mods bikec ((obj bikec)) + (let ((f30-0 (* 5461.3335 (-> obj controls steering))) + (f26-0 (* -5461.3335 (-> obj controls lean-z))) + (f28-0 (* 13653.333 (-> obj controls brake))) + (s5-0 (new 'static 'vector :x 1.0 :w 1.0)) + ) + (quaternion-vector-angle! (-> obj fin-fl rotation) s5-0 (- f26-0)) + (quaternion-vector-angle! (-> obj fin-fr rotation) s5-0 f26-0) + (quaternion-vector-angle! (-> obj fin2-fl rotation) s5-0 (- f26-0)) + (quaternion-vector-angle! (-> obj fin2-fr rotation) s5-0 f26-0) + (quaternion-vector-angle! (-> obj fin-rl rotation) s5-0 (+ f26-0 (* 0.2 f30-0))) + (quaternion-vector-angle! (-> obj fin-rr rotation) s5-0 (+ (- f26-0) (* 0.2 f30-0))) + (quaternion-vector-angle! (-> obj rudder rotation) s5-0 f30-0) + (quaternion-vector-angle! (-> obj brake-l rotation) s5-0 (- f28-0)) + (quaternion-vector-angle! (-> obj brake-r rotation) s5-0 f28-0) + (quaternion-vector-angle! (-> obj spoiler-l rotation) s5-0 f28-0) + (quaternion-vector-angle! (-> obj spoiler-r rotation) s5-0 (- f28-0)) + ) + 0 + (none) + ) + +;; definition for method 33 of type bikec +;; WARN: Return type mismatch int vs none. +(defmethod init-skel-and-rigid-body bikec ((obj bikec)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-bikec" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *bikec-constants*) + (set! (-> obj fin-fl) (new 'process 'joint-mod-rotate-local obj 7 #t)) + (set! (-> obj fin-fr) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 9 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 10 #t)) + (set! (-> obj fin2-fl) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj fin2-fr) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj rudder) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj brake-l) (new 'process 'joint-mod-rotate-local obj 11 #t)) + (set! (-> obj brake-r) (new 'process 'joint-mod-rotate-local obj 12 #t)) + (set! (-> obj spoiler-l) (new 'process 'joint-mod-rotate-local obj 13 #t)) + (set! (-> obj spoiler-r) (new 'process 'joint-mod-rotate-local obj 14 #t)) + 0 + (none) + ) + +;; definition for symbol *guard-bike-turret-control-info*, type turret-control-info +(define *guard-bike-turret-control-info* (new 'static 'turret-control-info + :joint-index 4 + :barrel-count 1 + :shot-speed 819200.0 + :attack-range 286720.0 + :rot-min (new 'static 'array float 2 -16384.0 -21845.334) + :rot-max (new 'static 'array float 2 0.0 21845.334) + :local-pos (new 'static 'vector :y -1433.6 :z 4096.0 :w 1.0) + :local-dir (new 'static 'vector :z 1.0 :w 1.0) + :barrel-array (new 'static 'inline-array turret-barrel-info 4 + (new 'static 'turret-barrel-info + :local-pos (new 'static 'vector :y -1433.6 :z 4096.0 :w 1.0) + :local-dir (new 'static 'vector :z 1.0 :w 1.0) + ) + (new 'static 'turret-barrel-info) + (new 'static 'turret-barrel-info) + (new 'static 'turret-barrel-info) + ) + ) + ) + +;; definition of type guard-bike +(deftype guard-bike (vehicle-guard) + ((turret-jm joint-mod-rotate-local :offset-assert 1076) + ) + :heap-base #x3c0 + :method-count-assert 159 + :size-assert #x438 + :flag-assert #x9f03c00438 + ) + +;; definition for method 3 of type guard-bike +(defmethod inspect guard-bike ((obj guard-bike)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type vehicle-guard inspect))) + (t9-0 obj) + ) + (format #t "~2Tturret-jm: ~A~%" (-> obj turret-jm)) + (label cfg-4) + obj + ) + +;; definition for method 7 of type guard-bike +(defmethod relocate guard-bike ((obj guard-bike) (arg0 int)) + (if (nonzero? (-> obj turret-jm)) + (&+! (-> obj turret-jm) arg0) + ) + ((the-as (function object int guard-bike) (find-parent-method guard-bike 7)) obj arg0) + ) + +;; definition for method 65 of type guard-bike +;; WARN: Return type mismatch int vs none. +(defmethod start-jump guard-bike ((obj guard-bike)) + (when (not (logtest? (rigid-body-object-flag jump-sound) (-> obj flags))) + (set! (-> obj flags) (logior (rigid-body-object-flag jump-sound) (-> obj flags))) + (sound-play "bike-hop") + ) + (set! (-> obj flags) (logior (rigid-body-object-flag jump) (-> obj flags))) + 0 + (none) + ) + +;; definition for method 32 of type guard-bike +;; WARN: Return type mismatch int vs none. +(defmethod allocate-and-init-cshape guard-bike ((obj guard-bike)) + (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) cshape-reaction-default) + (set! (-> s5-0 no-reaction) + (the-as (function collide-shape-moving collide-query vector vector object) nothing) + ) + (set! (-> s5-0 penetrate-using) (penetrate vehicle)) + (let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 5) 0))) + (set! (-> s5-0 total-prims) (the-as uint 6)) + (set! (-> s4-0 prim-core action) (collide-action solid)) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 13312.0) + (set! (-> s5-0 root-prim) s4-0) + ) + (let ((v1-11 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-11 prim-core action) (collide-action solid)) + (set! (-> v1-11 transform-index) 0) + (set-vector! (-> v1-11 local-sphere) 0.0 0.0 4505.6 4300.8) + ) + (let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-13 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-13 transform-index) 0) + (set-vector! (-> v1-13 local-sphere) 0.0 0.0 -3686.4 4096.0) + (set! (-> v1-13 nav-radius) 7168.0) + ) + (let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 96)))) + (set! (-> v1-15 prim-core action) (collide-action solid)) + (set! (-> v1-15 transform-index) 0) + (set-vector! (-> v1-15 local-sphere) 204.8 3276.8 1228.8 3276.8) + ) + (let ((v1-17 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1)))) + (set! (-> v1-17 prim-core action) (collide-action solid nav-sphere)) + (set! (-> v1-17 transform-index) 0) + (set-vector! (-> v1-17 local-sphere) 0.0 0.0 9011.2 3686.4) + (set! (-> v1-17 nav-radius) 7168.0) + ) + (let ((v1-19 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2)))) + (set! (-> v1-19 prim-core action) (collide-action solid)) + (set! (-> v1-19 transform-index) 0) + (set-vector! (-> v1-19 local-sphere) 0.0 -1638.4 -8192.0 3686.4) + ) + (set! (-> s5-0 nav-radius) 16384.0) + (let ((v1-21 (-> s5-0 root-prim))) + (set! (-> s5-0 backup-collide-as) (-> v1-21 prim-core collide-as)) + (set! (-> s5-0 backup-collide-with) (-> v1-21 prim-core collide-with)) + ) + (set! (-> s5-0 nav-flags) (nav-flags has-child-spheres)) + (set! (-> obj root-override-2) s5-0) + ) + 0 + (none) + ) + +;; definition for method 86 of type guard-bike +;; WARN: Return type mismatch int vs none. +(defmethod update-joint-mods guard-bike ((obj guard-bike)) + (update-joint-mod (-> obj turret) (-> obj turret-jm)) + 0 + (none) + ) + +;; definition for method 33 of type guard-bike +;; WARN: Return type mismatch int vs none. +(defmethod init-skel-and-rigid-body guard-bike ((obj guard-bike)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-guard-bike" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *guard-bike-constants*) + (set-info (-> obj turret) *guard-bike-turret-control-info*) + (set! (-> obj turret-jm) (new 'process 'joint-mod-rotate-local obj (-> obj turret info joint-index) #t)) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak2/levels/city/common/ctyport-obs_REF.gc b/test/decompiler/reference/jak2/levels/city/common/ctyport-obs_REF.gc index ceed2eec50..dae0e565e7 100644 --- a/test/decompiler/reference/jak2/levels/city/common/ctyport-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/ctyport-obs_REF.gc @@ -491,7 +491,7 @@ 0 ) ) - (vehicle-method-85 obj) + (draw-thrusters obj) (none) ) ) @@ -573,7 +573,7 @@ ;; definition for method 36 of type boat-base ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-36 boat-base ((obj boat-base)) +(defmethod do-engine-sounds boat-base ((obj boat-base)) 0 (none) ) @@ -623,8 +623,8 @@ ;; definition for method 31 of type boat-base ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-31 boat-base ((obj boat-base) (arg0 rigid-body-vehicle-constants)) - ((method-of-type vehicle rigid-body-object-method-31) obj arg0) +(defmethod alloc-and-init-rigid-body-control boat-base ((obj boat-base) (arg0 rigid-body-vehicle-constants)) + ((method-of-type vehicle alloc-and-init-rigid-body-control) obj arg0) 0 (none) ) @@ -788,7 +788,7 @@ ;; definition for method 32 of type barge ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-32 barge ((obj barge)) +(defmethod allocate-and-init-cshape barge ((obj barge)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -910,13 +910,13 @@ ;; definition for method 33 of type barge ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-33 barge ((obj barge)) +(defmethod init-skel-and-rigid-body barge ((obj barge)) (initialize-skeleton obj (the-as skeleton-group (art-group-get-by-name *level* "skel-barge" (the-as (pointer uint32) #f))) (the-as pair 0) ) - (rigid-body-object-method-31 obj *barge-constants*) + (alloc-and-init-rigid-body-control obj *barge-constants*) (set! (-> obj draw lod-set lod 0 dist) 1228800.0) (set! (-> obj engine) (the-as uint (new-sound-id))) (set! (-> obj bow-wash) (the-as uint (new-sound-id))) diff --git a/test/decompiler/reference/jak2/levels/city/common/ctywide-tasks_REF.gc b/test/decompiler/reference/jak2/levels/city/common/ctywide-tasks_REF.gc index eb09451845..3348b83250 100644 --- a/test/decompiler/reference/jak2/levels/city/common/ctywide-tasks_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/ctywide-tasks_REF.gc @@ -429,7 +429,7 @@ ) (set! (-> gp-0 position quad) (-> self begin-pos quad)) (quaternion-axis-angle! (-> gp-0 rotation) 0.0 1.0 0.0 16384.0) - (set! (-> gp-0 object-type) (the-as uint 13)) + (set! (-> gp-0 object-type) (traffic-type bikec)) (set! (-> gp-0 behavior) (the-as uint 0)) (set! (-> gp-0 id) (the-as uint 0)) (set! (-> gp-0 proc) #f) @@ -709,7 +709,7 @@ ) (s5-0 (new 'stack-no-clear 'traffic-object-spawn-params)) ) - (set! (-> s5-0 object-type) (the-as uint 6)) + (set! (-> s5-0 object-type) (traffic-type crimson-guard-1)) (set! (-> s5-0 behavior) (the-as uint 9)) (set! (-> s5-0 id) (the-as uint 0)) (set! (-> s5-0 nav-mesh) #f) @@ -808,7 +808,7 @@ ) (set! (-> s5-0 position quad) (-> gp-0 bike-pos quad)) (quaternion-axis-angle! (-> s5-0 rotation) 0.0 1.0 0.0 (-> gp-0 bike-angle)) - (set! (-> s5-0 object-type) (the-as uint 11)) + (set! (-> s5-0 object-type) (traffic-type bikea)) (set! (-> s5-0 behavior) (the-as uint 0)) (set! (-> s5-0 id) (the-as uint 0)) (set! (-> s5-0 proc) #f) diff --git a/test/decompiler/reference/jak2/levels/city/common/height-map-h_REF.gc b/test/decompiler/reference/jak2/levels/city/common/height-map-h_REF.gc index 6c54c292d8..bedb8e2c40 100644 --- a/test/decompiler/reference/jak2/levels/city/common/height-map-h_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/height-map-h_REF.gc @@ -22,12 +22,12 @@ all initialized from static data." :size-assert #x20 :flag-assert #xf00000020 (:methods - (xz-height-map-method-9 (_type_ vector) float 9) - (xz-height-map-method-10 (_type_ vector) none 10) - (xz-height-map-method-11 (_type_) none 11) - (xz-height-map-method-12 (_type_ vector) none 12) - (xz-height-map-method-13 (_type_ vector) none 13) - (xz-height-map-method-14 (_type_ vector int) none 14) + (get-height-at-point (_type_ vector) float 9) + (debug-draw-mesh (_type_ vector) none 10) + (debug-print (_type_) none 11) + (debug-draw-at-point (_type_ vector) none 12) + (debug-draw (_type_ vector) none 13) + (debug-add-offset (_type_ vector int) none 14) ) ) @@ -57,5 +57,5 @@ all initialized from static data." (defun get-traffic-height ((arg0 vector)) "@returns The value of [[xz-height-map::9]] using [[*traffic-height-map*]] and the [[vector]] provided @see [[xz-height-map::9]]" - (xz-height-map-method-9 *traffic-height-map* arg0) + (get-height-at-point *traffic-height-map* arg0) ) diff --git a/test/decompiler/reference/jak2/levels/city/common/height-map_REF.gc b/test/decompiler/reference/jak2/levels/city/common/height-map_REF.gc new file mode 100644 index 0000000000..044ac996cd --- /dev/null +++ b/test/decompiler/reference/jak2/levels/city/common/height-map_REF.gc @@ -0,0 +1,264 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 11 of type xz-height-map +;; WARN: Return type mismatch int vs none. +(defmethod debug-print xz-height-map ((obj xz-height-map)) + (format #t "(define *traffic-height-map*~%") + (format #t " (static-height-map~%") + (format + #t + " :offset ((meters ~M) (meters ~M) (meters ~M))~%" + (-> obj x-offset) + (-> obj y-offset) + (-> obj z-offset) + ) + (format #t " :x-spacing (meters ~M)~%" (/ 1.0 (-> obj x-inv-spacing))) + (format #t " :z-spacing (meters ~M)~%" (/ 1.0 (-> obj z-inv-spacing))) + (format #t " :y-scale (meters ~M)~%" (-> obj y-scale)) + (format #t " :x-dim ~d~%" (-> obj x-dim)) + (format #t " :z-dim ~d~%" (-> obj z-dim)) + (format #t " :data~%") + (format #t " (~%") + (let ((s5-0 0)) + (dotimes (s4-0 (-> obj z-dim)) + (dotimes (s3-0 (-> obj x-dim)) + (format #t " ~2d" (-> obj data s5-0)) + (+! s5-0 1) + ) + (format #t "~%") + ) + ) + (format #t "~T)~%") + (format #t " )~%") + (format #t " )~%~%") + 0 + (none) + ) + +;; definition for method 14 of type xz-height-map +;; WARN: Return type mismatch int vs none. +(defmethod debug-add-offset xz-height-map ((obj xz-height-map) (arg0 vector) (arg1 int)) + "Add an offset to the given point, likely for debugging purposes." + (let ((v1-1 (the int (+ 0.5 (* (- (-> arg0 x) (-> obj x-offset)) (-> obj x-inv-spacing))))) + (a1-1 (the int (+ 0.5 (* (- (-> arg0 z) (-> obj z-offset)) (-> obj z-inv-spacing))))) + ) + (when (and (>= v1-1 0) (< v1-1 (-> obj x-dim)) (>= a1-1 0) (< a1-1 (-> obj z-dim))) + (let ((v1-2 (+ v1-1 (* a1-1 (-> obj x-dim))))) + (+! (-> obj data v1-2) arg1) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type xz-height-map +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw-at-point xz-height-map ((obj xz-height-map) (arg0 vector)) + (let ((v1-1 (the int (+ 0.5 (* (- (-> arg0 x) (-> obj x-offset)) (-> obj x-inv-spacing))))) + (a1-1 (the int (+ 0.5 (* (- (-> arg0 z) (-> obj z-offset)) (-> obj z-inv-spacing))))) + (a2-1 (-> obj x-dim)) + (a3-0 (-> obj z-dim)) + ) + (when (and (>= v1-1 0) (< v1-1 a2-1) (>= a1-1 0) (< a1-1 a3-0)) + (let* ((a2-3 (+ v1-1 (* a1-1 a2-1))) + (gp-0 (-> obj data a2-3)) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (set! (-> s5-0 x) (+ (-> obj x-offset) (/ (the float v1-1) (-> obj x-inv-spacing)))) + (set! (-> s5-0 y) 0.0) + (set! (-> s5-0 z) (+ (-> obj z-offset) (/ (the float a1-1) (-> obj z-inv-spacing)))) + (set! (-> s5-0 y) (get-height-at-point obj s5-0)) + (let ((s4-0 add-debug-text-3d) + (s3-0 #t) + (s2-0 318) + ) + (format (clear *temp-string*) "~D" gp-0) + (s4-0 + s3-0 + (the-as bucket-id s2-0) + *temp-string* + s5-0 + (font-color #dadada) + (new 'static 'vector2h :data (new 'static 'array int16 2 0 16)) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 9 of type xz-height-map +(defmethod get-height-at-point xz-height-map ((obj xz-height-map) (arg0 vector)) + (let* ((f0-1 (fmax 0.0 (* (-> obj x-inv-spacing) (- (-> arg0 x) (-> obj x-offset))))) + (f2-4 (fmax 0.0 (* (-> obj z-inv-spacing) (- (-> arg0 z) (-> obj z-offset))))) + (a2-0 (the int f0-1)) + (a1-1 (the int f2-4)) + (f1-7 (- f0-1 (the float a2-0))) + (f0-4 (- f2-4 (the float a1-1))) + (v1-0 (-> obj x-dim)) + (a3-0 (-> obj z-dim)) + (a1-7 + (the-as + (pointer int8) + (+ (+ (min a2-0 (+ v1-0 -2)) (* (min a1-1 (+ a3-0 -2)) v1-0) 0) (the-as int (the-as pointer (-> obj data)))) + ) + ) + (f3-3 (the float (-> a1-7 0))) + (f4-1 (the float (-> a1-7 1))) + (f2-8 (the float (-> a1-7 v1-0))) + (f5-1 (the float (-> a1-7 (+ v1-0 1)))) + (f3-5 (+ (* f3-3 (- 1.0 f1-7)) (* f4-1 f1-7))) + (f1-9 (+ (* f2-8 (- 1.0 f1-7)) (* f5-1 f1-7))) + ) + (+ (* (+ (* f3-5 (- 1.0 f0-4)) (* f1-9 f0-4)) (-> obj y-scale)) (-> obj y-offset)) + ) + ) + +;; definition for function point-in-bbox? +(defun point-in-bbox? ((arg0 bounding-box) (arg1 vector)) + (and (>= (-> arg1 x) (-> arg0 min x)) + (>= (-> arg1 y) (-> arg0 min y)) + (>= (-> arg1 z) (-> arg0 min z)) + (>= (-> arg0 max x) (-> arg1 x)) + (>= (-> arg0 max y) (-> arg1 y)) + (>= (-> arg0 max z) (-> arg1 z)) + ) + ) + +;; definition for method 10 of type xz-height-map +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw-mesh xz-height-map ((obj xz-height-map) (arg0 vector)) + (local-vars (sv-80 int) (sv-96 int)) + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (mem-copy! (the-as pointer (-> s5-0 vector 2)) (the-as pointer arg0) 32) + (.svf (&-> (-> s5-0 vector) 0 quad) vf0) + (let ((f30-0 (/ 1.0 (-> obj z-inv-spacing))) + (f28-0 (/ 1.0 (-> obj x-inv-spacing))) + (s4-0 (-> obj x-dim)) + (s3-0 (-> obj z-dim)) + ) + (let ((s2-0 (&-> (-> obj data) 0))) + (set! (-> s5-0 vector 0 z) (-> obj z-offset)) + (countdown (s1-0 s3-0) + (let ((s0-0 s2-0)) + (set! (-> s5-0 vector 0 x) (-> obj x-offset)) + (set! (-> s5-0 vector 0 y) (+ (-> obj y-offset) (* (the float (-> s0-0 0)) (-> obj y-scale)))) + (set! sv-80 (+ s4-0 -1)) + (while (nonzero? sv-80) + (set! sv-80 (+ sv-80 -1)) + (set! (-> s5-0 vector 1 quad) (-> s5-0 vector 0 quad)) + (+! (-> s5-0 vector 0 x) f28-0) + (set! s0-0 (&-> s0-0 1)) + (set! (-> s5-0 vector 0 y) (+ (-> obj y-offset) (* (the float (-> s0-0 0)) (-> obj y-scale)))) + (if (and (point-in-bbox? (the-as bounding-box (-> s5-0 vector 2)) (the-as vector (-> s5-0 vector))) + (point-in-bbox? (the-as bounding-box (-> s5-0 vector 2)) (-> s5-0 vector 1)) + ) + (add-debug-line + #t + (bucket-id debug2) + (the-as vector (-> s5-0 vector)) + (-> s5-0 vector 1) + *color-red* + #f + (the-as rgba -1) + ) + ) + ) + ) + (+! (-> s5-0 vector 0 z) f30-0) + (&+! s2-0 s4-0) + ) + ) + (let ((s2-1 (&-> (-> obj data) 0))) + (set! (-> s5-0 vector 0 x) (-> obj x-offset)) + (countdown (s1-1 s4-0) + (let ((s0-1 (the-as pointer s2-1))) + (set! (-> s5-0 vector 0 z) (-> obj z-offset)) + (set! (-> s5-0 vector 0 y) + (+ (-> obj y-offset) (* (the float (-> (the-as (pointer int8) s0-1) 0)) (-> obj y-scale))) + ) + (set! sv-96 (+ s3-0 -1)) + (while (nonzero? sv-96) + (set! sv-96 (+ sv-96 -1)) + (set! (-> s5-0 vector 1 quad) (-> s5-0 vector 0 quad)) + (+! (-> s5-0 vector 0 z) f30-0) + (&+! s0-1 s4-0) + (set! (-> s5-0 vector 0 y) + (+ (-> obj y-offset) (* (the float (-> (the-as (pointer int8) s0-1))) (-> obj y-scale))) + ) + (if (and (point-in-bbox? (the-as bounding-box (-> s5-0 vector 2)) (the-as vector (-> s5-0 vector))) + (point-in-bbox? (the-as bounding-box (-> s5-0 vector 2)) (-> s5-0 vector 1)) + ) + (add-debug-line + #t + (bucket-id debug2) + (the-as vector (-> s5-0 vector)) + (-> s5-0 vector 1) + *color-blue* + #f + (the-as rgba -1) + ) + ) + ) + ) + (+! (-> s5-0 vector 0 x) f28-0) + (set! s2-1 (&-> s2-1 1)) + ) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 13 of type xz-height-map +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw xz-height-map ((obj xz-height-map) (arg0 vector)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((v1-0 (new 'stack-no-clear 'vector4w-2))) + (let ((a1-1 (-> v1-0 vector))) + (let ((a0-1 arg0)) + (let ((a2-1 -573440.0)) + (.mov vf6 a2-1) + ) + (.lvf vf4 (&-> a0-1 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a1-1 0 quad) vf5) + ) + (let ((a1-2 (-> v1-0 vector 1))) + (let ((a0-2 arg0)) + (let ((a2-3 573440.0)) + (.mov vf6 a2-3) + ) + (.lvf vf4 (&-> a0-2 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a1-2 quad) vf5) + ) + (debug-draw-mesh obj (the-as vector (-> v1-0 vector))) + ) + (debug-draw-at-point obj arg0) + 0 + (none) + ) + ) + + + + diff --git a/test/decompiler/reference/jak2/levels/city/common/nav-graph-h_REF.gc b/test/decompiler/reference/jak2/levels/city/common/nav-graph-h_REF.gc index 6c3a602a82..0c45a21145 100644 --- a/test/decompiler/reference/jak2/levels/city/common/nav-graph-h_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/nav-graph-h_REF.gc @@ -3,35 +3,35 @@ ;; definition of type nav-branch (deftype nav-branch (structure) - ((node int32 2 :offset-assert 0) - (src-node nav-node :offset 0) - (dest-node nav-node :offset 4) - (temp-dest-node-id int32 :offset 4) - (speed-limit uint8 :offset-assert 8) - (density uint8 :offset-assert 9) - (clock-type uint8 :offset-assert 10) - (clock-mask uint8 :offset-assert 11) - (max-user-count uint8 :offset-assert 12) - (user-count uint8 :offset-assert 13) - (width uint8 :offset-assert 14) - (flags uint8 :offset-assert 15) + ((node nav-node 2 :offset-assert 0) + (src-node nav-node :offset 0) + (dest-node nav-node :offset 4) + (temp-dest-node-id int32 :offset 4) + (speed-limit uint8 :offset-assert 8) + (density uint8 :offset-assert 9) + (clock-type nav-branch-clock-type :offset-assert 10) + (clock-mask nav-branch-clock-mask :offset-assert 11) + (max-user-count uint8 :offset-assert 12) + (user-count uint8 :offset-assert 13) + (width uint8 :offset-assert 14) + (flags uint8 :offset-assert 15) ) :method-count-assert 21 :size-assert #x10 :flag-assert #x1500000010 (:methods - (nav-branch-method-9 (_type_) none 9) - (nav-branch-method-10 (_type_ object int) none 10) + (set-default-density-speed-and-width (_type_) none 9) + (debug-print (_type_ object int) none 10) (get-density (_type_) float 11) (get-speed-limit (_type_) float 12) (get-width (_type_) float 13) (user-limit-reached? (_type_) symbol 14) (dest-node-id-at-max? (_type_) symbol 15) - (nav-branch-method-16 (_type_ float) none 16) - (nav-branch-method-17 (_type_ float) none 17) - (nav-branch-method-18 (_type_ float) none 18) - (nav-branch-method-19 (_type_ nav-node) none 19) - (nav-branch-method-20 (_type_ nav-node) none 20) + (set-density (_type_ float) none 16) + (set-speed-limit (_type_ float) none 17) + (set-width (_type_ float) none 18) + (set-src-node (_type_ nav-node) none 19) + (set-dst-node (_type_ nav-node) none 20) ) ) @@ -79,15 +79,15 @@ :size-assert #x20 :flag-assert #x1600000020 (:methods - (nav-node-method-9 (_type_) none 9) - (nav-node-method-10 (_type_ symbol string) none 10) - (nav-node-method-11 (_type_ int) none 11) - (nav-node-method-12 (_type_ vector nav-node) none 12) - (nav-node-method-13 (_type_ vector) none 13) - (nav-node-method-14 (_type_ vector) none 14) - (nav-node-method-15 (_type_ uint) none 15) - (nav-node-method-16 (_type_ float) none 16) - (nav-node-method-17 (_type_ float) none 17) + (debug-draw (_type_) none 9) + (debug-print (_type_ symbol string) none 10) + (remove-branch-by-idx (_type_ int) none 11) + (init-from-pt-and-heading (_type_ vector vector) none 12) + (set-pos-xyz (_type_ vector) none 13) + (set-angle-from-heading (_type_ vector) none 14) + (set-id-and-link-branches-back (_type_ uint) none 15) + (set-radius (_type_ float) none 16) + (set-angle (_type_ float) none 17) (get-position (_type_ vector) vector 18) (calc-sine-and-cosine! (_type_ vector) vector 19) (get-angle (_type_) float 20) @@ -261,42 +261,42 @@ :flag-assert #x2d0000003c (:methods (new (symbol type int int int uint) _type_ 0) - (nav-graph-method-9 (_type_) none 9) + (debug-draw-nodes (_type_) none 9) (nav-graph-method-10 (_type_ vector int) none 10) (nav-graph-method-11 (_type_) none 11) (nav-graph-method-12 (_type_) none 12) (nav-graph-method-13 (_type_ int int) none 13) (nav-graph-method-14 (_type_ int int) none 14) - (nav-graph-method-15 (_type_) none 15) - (nav-graph-method-16 (_type_ int) nav-node 16) - (nav-graph-method-17 (_type_ nav-node) none 17) - (nav-graph-method-18 (_type_ nav-node int) none 18) + (debug-reset (_type_) none 15) + (debug-add-node (_type_ int) nav-node 16) + (debug-link-node-to-graph (_type_ nav-node) none 17) + (debug-reset-branch-array (_type_ nav-node int) none 18) (nav-graph-method-19 (_type_ int int int int int int) none 19) (nav-graph-method-20 (_type_ int int) none 20) - (nav-graph-method-21 (_type_) none 21) - (nav-graph-method-22 (_type_ int int) none 22) - (nav-graph-method-23 (_type_ int int) none 23) - (nav-graph-method-24 (_type_ int int) none 24) - (nav-graph-method-25 (_type_ symbol symbol) none 25) - (nav-graph-method-26 (_type_ symbol symbol) none 26) - (nav-graph-method-27 (_type_ nav-node-flag-byte nav-node-flag-byte symbol) none 27) - (nav-graph-method-28 (_type_) none 28) - (nav-graph-method-29 (_type_ symbol) none 29) - (nav-graph-method-30 (_type_ uint) none 30) - (nav-graph-method-31 (_type_ float) none 31) - (nav-graph-method-32 (_type_ float) none 32) - (nav-graph-method-33 (_type_ float) none 33) - (nav-graph-method-34 (_type_ float) none 34) - (nav-graph-method-35 (_type_ int) none 35) - (nav-graph-method-36 (_type_ int) none 36) - (nav-graph-method-37 (_type_ vector) none 37) + (move-selected-to-height-map-height (_type_) none 21) + (select-nodes-in-range (_type_ int int) none 22) + (deselect-nodes-in-range (_type_ int int) none 23) + (toggle-select-nodes-in-range (_type_ int int) none 24) + (select-nodes-in-level (_type_ symbol symbol) none 25) + (select-nodes-by-nav-mesh-id (_type_ int symbol) none 26) + (select-nodes-by-flags (_type_ nav-node-flag-byte nav-node-flag-byte symbol) none 27) + (print-selected-nodes (_type_) none 28) + (assign-selected-nodes-to-level (_type_ symbol) none 29) + (assign-selected-nodes-to-nav-mesh (_type_ uint) none 30) + (set-radius-of-selected-nodes (_type_ float) none 31) + (set-speed-limit-of-selected (_type_ float) none 32) + (set-density-of-selected (_type_ float) none 33) + (set-width-of-selected (_type_ float) none 34) + (or-flags-of-selected-nodes (_type_ nav-node-flag-byte) none 35) + (and-flags-of-selected-nodes (_type_ nav-node-flag-byte) none 36) + (offset-pos-of-selected (_type_ vector) none 37) (nav-graph-method-38 (_type_) none 38) (nav-graph-method-39 (_type_) none 39) (nav-graph-method-40 (_type_ int) int 40) (node-at-idx (_type_ int) nav-node 41) - (nav-graph-method-42 (_type_) none 42) - (nav-graph-method-43 (_type_ nav-graph-link string) none 43) - (from-editor (_type_ nav-node symbol) none 44) + (patch-nodes (_type_) none 42) + (copy-to-mysql-graph (_type_ mysql-nav-graph string) none 43) + (from-editor (_type_ mysql-nav-graph symbol) none 44) ) ) diff --git a/test/decompiler/reference/jak2/levels/city/common/nav-graph_REF.gc b/test/decompiler/reference/jak2/levels/city/common/nav-graph_REF.gc new file mode 100644 index 0000000000..773cd2bbff --- /dev/null +++ b/test/decompiler/reference/jak2/levels/city/common/nav-graph_REF.gc @@ -0,0 +1,1475 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 16 of type nav-branch +;; WARN: Return type mismatch int vs none. +(defmethod set-density nav-branch ((obj nav-branch) (arg0 float)) + (set! (-> obj density) (the-as uint (max 0 (min 255 (the int (+ 0.5 (* 128.0 arg0))))))) + 0 + (none) + ) + +;; definition for method 17 of type nav-branch +;; WARN: Return type mismatch int vs none. +(defmethod set-speed-limit nav-branch ((obj nav-branch) (arg0 float)) + (set! (-> obj speed-limit) (the-as uint (max 0 (min 255 (the int (+ 0.5 (* 0.0009765625 arg0))))))) + 0 + (none) + ) + +;; definition for method 18 of type nav-branch +;; WARN: Return type mismatch int vs none. +(defmethod set-width nav-branch ((obj nav-branch) (arg0 float)) + (set! (-> obj width) (the-as uint (max 0 (min 255 (the int (+ 0.5 (* 0.00390625 arg0))))))) + 0 + (none) + ) + +;; definition for method 19 of type nav-branch +;; WARN: Return type mismatch int vs none. +(defmethod set-src-node nav-branch ((obj nav-branch) (arg0 nav-node)) + (set! (-> obj src-node) arg0) + 0 + (none) + ) + +;; definition for method 20 of type nav-branch +;; WARN: Return type mismatch int vs none. +(defmethod set-dst-node nav-branch ((obj nav-branch) (arg0 nav-node)) + (set! (-> obj dest-node) arg0) + 0 + (none) + ) + +;; definition for method 9 of type nav-branch +;; WARN: Return type mismatch int vs none. +(defmethod set-default-density-speed-and-width nav-branch ((obj nav-branch)) + (set-density obj 0.25) + (set-speed-limit obj 61440.0) + (set-width obj 16384.0) + 0 + (none) + ) + +;; definition for method 9 of type nav-node +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw nav-node ((obj nav-node)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'sphere)) + ) + (let ((a1-0 obj) + (v1-0 gp-0) + ) + (set! (-> v1-0 quad) (-> a1-0 position quad)) + (set! (-> v1-0 w) 1.0) + ) + (set! (-> s4-0 quad) (-> gp-0 quad)) + (let ((v1-2 obj)) + (set! (-> s4-0 r) (* 1024.0 (the float (-> v1-2 radius)))) + ) + (when (logtest? (-> obj flags) (nav-node-flag-byte selected)) + (let ((v1-8 (new 'stack-no-clear 'nav-graph-link))) + (let ((a1-3 (&-> v1-8 id))) + (let ((a0-6 gp-0)) + (let ((a2-1 -8192.0)) + (.mov vf6 a2-1) + ) + (.lvf vf4 (&-> a0-6 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (the-as (pointer uint128) (&-> a1-3 0)) vf5) + ) + (let ((a1-4 (-> v1-8 dummy-node))) + (let ((a0-7 gp-0)) + (let ((a2-3 8192.0)) + (.mov vf6 a2-3) + ) + (.lvf vf4 (&-> a0-7 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a1-4 position quad) vf5) + ) + (add-debug-box + #t + (bucket-id debug2) + (the-as vector (&-> v1-8 id)) + (the-as vector (-> v1-8 dummy-node)) + *color-yellow* + ) + ) + ) + (when (and (not (logtest? (-> obj flags) (nav-node-flag-byte hidden))) + (let ((f0-6 (vector-vector-distance-squared gp-0 (camera-pos))) + (f1-2 327680.0) + ) + (and (< f0-6 (* f1-2 f1-2)) (sphere-in-view-frustum? s4-0)) + ) + ) + (add-debug-x #t (bucket-id debug2) gp-0 *color-red*) + (let ((s4-1 add-debug-text-3d) + (s3-1 #t) + (s2-1 324) + ) + (format (clear *temp-string*) "~D ~D" (-> obj id) (-> obj nav-mesh-id)) + (s4-1 + s3-1 + (the-as bucket-id s2-1) + *temp-string* + gp-0 + (if (logtest? (-> obj flags) (nav-node-flag-byte blocked)) + (font-color precursor-#ec3b00) + (font-color cyan-#00fefe) + ) + (the-as vector2h #f) + ) + ) + (let ((s4-2 add-debug-vector) + (s3-2 #t) + (s2-2 324) + (s1-1 (new 'stack-no-clear 'vector)) + ) + (let ((f0-8 (the float (-> obj angle))) + (s5-1 (new 'stack-no-clear 'vector)) + ) + (sincos! s5-1 f0-8) + (set! (-> s1-1 x) (-> s5-1 y)) + (set! (-> s1-1 y) 0.0) + (set! (-> s1-1 z) (- (-> s5-1 x))) + ) + (set! (-> s1-1 w) 1.0) + (s4-2 s3-2 (the-as bucket-id s2-2) gp-0 s1-1 (meters 2) *color-green*) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 10 of type nav-branch +;; WARN: Return type mismatch int vs none. +(defmethod debug-print nav-branch ((obj nav-branch) (arg0 object) (arg1 int)) + (format arg0 "~S~T~T~T (new-nav-branch :dest-node-id ~d~%" arg1 (-> obj dest-node id)) + (let ((t9-1 format) + (a0-2 arg0) + (a1-2 "~S~T~T~T~T~T :density ~4,,3f~%") + (a2-2 arg1) + (v1-1 obj) + ) + (t9-1 a0-2 a1-2 a2-2 (* 0.0078125 (the float (-> v1-1 density)))) + ) + (let ((t9-2 format) + (a0-3 arg0) + (a1-3 "~S~T~T~T~T~T :width ~4,,3M~%") + (a2-3 arg1) + (v1-3 obj) + ) + (t9-2 a0-3 a1-3 a2-3 (* 256.0 (the float (-> v1-3 width)))) + ) + (let ((t9-3 format) + (a0-4 arg0) + (a1-4 "~S~T~T~T~T~T :speed-limit ~4,,3M~%") + (a2-4 arg1) + (v1-5 obj) + ) + (t9-3 a0-4 a1-4 a2-4 (* 1024.0 (the float (-> v1-5 speed-limit)))) + ) + (when (nonzero? (-> obj clock-type)) + (let ((t9-4 format) + (a0-5 arg0) + (a1-5 "~S~T~T~T~T~T :clock-type ~S~%") + (a2-5 arg1) + (v1-9 (-> obj clock-type)) + ) + (t9-4 a0-5 a1-5 a2-5 (cond + ((= v1-9 (nav-branch-clock-type clock3)) + "clock3" + ) + ((= v1-9 (nav-branch-clock-type no-clock)) + "no-clock" + ) + ((= v1-9 (nav-branch-clock-type clock2)) + "clock2" + ) + ((= v1-9 (nav-branch-clock-type clock4)) + "clock4" + ) + (else + "*unknown*" + ) + ) + ) + ) + (format arg0 "~S~T~T~T~T~T :clock-mask (" arg1) + (let ((s4-1 (-> obj clock-mask))) + (if (= (logand s4-1 (nav-branch-clock-mask phase-1a)) (nav-branch-clock-mask phase-1a)) + (format arg0 "phase-1a ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-2a)) (nav-branch-clock-mask phase-2a)) + (format arg0 "phase-2a ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-1)) (nav-branch-clock-mask phase-1)) + (format arg0 "phase-1 ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-3a)) (nav-branch-clock-mask phase-3a)) + (format arg0 "phase-3a ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-2)) (nav-branch-clock-mask phase-2)) + (format arg0 "phase-2 ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-4a)) (nav-branch-clock-mask phase-4a)) + (format arg0 "phase-4a ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-3)) (nav-branch-clock-mask phase-3)) + (format arg0 "phase-3 ") + ) + (if (= (logand s4-1 (nav-branch-clock-mask phase-4)) (nav-branch-clock-mask phase-4)) + (format arg0 "phase-4 ") + ) + ) + (format arg0 ")~%") + ) + (format arg0 "~S~T~T~T~T~T )~%" arg1) + 0 + (none) + ) + +;; definition for method 10 of type nav-node +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod debug-print nav-node ((obj nav-node) (arg0 symbol) (arg1 string)) + (format arg0 "~S (new-nav-node :id ~d~%" arg1 (-> obj id)) + (format arg0 "~S~T :branch-list (~%" arg1) + (dotimes (s3-0 (-> obj branch-count)) + (debug-print (-> obj branch-array s3-0) arg0 (the-as int arg1)) + ) + (format arg0 "~S~T~T~T )~%" arg1) + (let* ((v1-6 (-> obj flags)) + (s3-1 (logclear v1-6 (nav-node-flag-byte visited blocked))) + ) + (when (nonzero? s3-1) + (format arg0 "~S~T :flags (" arg1) + (if (= (logand s3-1 (nav-node-flag-byte blocked)) (nav-node-flag-byte blocked)) + (format arg0 "blocked ") + ) + (if (= (logand s3-1 (nav-node-flag-byte selected)) (nav-node-flag-byte selected)) + (format arg0 "selected ") + ) + (if (= (logand s3-1 (nav-node-flag-byte pedestrian)) (nav-node-flag-byte pedestrian)) + (format arg0 "pedestrian ") + ) + (if (= (logand s3-1 (nav-node-flag-byte visited)) (nav-node-flag-byte visited)) + (format arg0 "visited ") + ) + (if (= (logand s3-1 (nav-node-flag-byte hidden)) (nav-node-flag-byte hidden)) + (format arg0 "hidden ") + ) + (format arg0 ")~%") + ) + ) + (let ((v1-24 (new 'stack-no-clear 'vector))) + (let ((a2-6 obj) + (a0-19 v1-24) + ) + (set! (-> a0-19 quad) (-> a2-6 position quad)) + (set! (-> a0-19 w) 1.0) + ) + (format arg0 "~S~T :position (~4,,2M ~4,,2M ~4,,2M)~%" arg1 (-> v1-24 x) (-> v1-24 y) (-> v1-24 z)) + ) + (format arg0 "~S~T :angle ~4,,3f~%" arg1 (* 0.005493164 (the float (-> obj angle)))) + (let ((t9-13 format) + (a0-22 arg0) + (a1-16 "~S~T :radius ~4,,2M~%") + (a2-11 arg1) + (v1-30 obj) + ) + (t9-13 a0-22 a1-16 a2-11 (* 1024.0 (the float (-> v1-30 radius)))) + ) + (if (nonzero? (-> obj nav-mesh-id)) + (format arg0 "~S~T :nav-mesh-id ~d~%" arg1 (-> obj nav-mesh-id)) + ) + (if (-> obj level) + (format arg0 "~S~T :level ~s~%" arg1 (-> obj level)) + ) + (format arg0 "~S~T )~%" arg1) + 0 + (none) + ) + +;; definition for method 13 of type nav-node +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod set-pos-xyz nav-node ((obj nav-node) (arg0 vector)) + (let ((f0-0 (-> obj position w))) + (set! (-> obj position quad) (-> arg0 quad)) + (set! (-> obj position w) f0-0) + ) + 0 + (none) + ) + +;; definition for method 14 of type nav-node +;; WARN: Return type mismatch int vs none. +(defmethod set-angle-from-heading nav-node ((obj nav-node) (arg0 vector)) + (set! (-> obj angle) (the-as uint (the int (atan (- (-> arg0 z)) (-> arg0 x))))) + 0 + (none) + ) + +;; definition for method 16 of type nav-node +;; WARN: Return type mismatch int vs none. +(defmethod set-radius nav-node ((obj nav-node) (arg0 float)) + (set! (-> obj radius) (the-as uint (max 0 (min 255 (the int (+ 0.5 (* 0.0009765625 arg0))))))) + 0 + (none) + ) + +;; definition for method 17 of type nav-node +;; WARN: Return type mismatch int vs none. +(defmethod set-angle nav-node ((obj nav-node) (arg0 float)) + (set! (-> obj angle) (the-as uint (the int (+ 0.5 arg0)))) + 0 + (none) + ) + +;; definition for method 15 of type nav-node +;; WARN: Return type mismatch int vs none. +(defmethod set-id-and-link-branches-back nav-node ((obj nav-node) (arg0 uint)) + (set! (-> obj id) arg0) + (dotimes (v1-0 (-> obj branch-count)) + (set! (-> obj branch-array v1-0 src-node) obj) + ) + 0 + (none) + ) + +;; definition for method 12 of type nav-node +;; WARN: Return type mismatch int vs none. +(defmethod init-from-pt-and-heading nav-node ((obj nav-node) (arg0 vector) (arg1 vector)) + (set-pos-xyz obj arg0) + (set-angle-from-heading obj arg1) + (set! (-> obj flags) (nav-node-flag-byte pedestrian selected)) + (set-radius obj 32768.0) + (set! (-> obj level) 'ctyport) + (set! (-> obj nav-mesh-id) (the-as uint 0)) + (dotimes (s5-1 (-> obj branch-count)) + (set-default-density-speed-and-width (-> obj branch-array s5-1)) + ) + 0 + (none) + ) + +;; definition for method 11 of type nav-node +;; WARN: Return type mismatch int vs none. +(defmethod remove-branch-by-idx nav-node ((obj nav-node) (arg0 int)) + (when (and (>= arg0 0) (< arg0 (-> obj branch-count))) + (let ((s5-0 (+ arg0 1)) + (s4-0 arg0) + ) + (while (< s5-0 (-> obj branch-count)) + (mem-copy! (the-as pointer (-> obj branch-array s4-0)) (the-as pointer (-> obj branch-array s5-0)) 16) + (+! s5-0 1) + (+! s4-0 1) + ) + ) + (+! (-> obj branch-count) -1) + ) + 0 + (none) + ) + +;; definition for method 18 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod debug-reset-branch-array nav-graph ((obj nav-graph) (arg0 nav-node) (arg1 int)) + "kinda dangerous" + (set! (-> arg0 branch-array) (the-as (inline-array nav-branch) (-> obj branch-array (-> obj branch-count)))) + (set! (-> arg0 branch-count) arg1) + (+! (-> obj branch-count) arg1) + (dotimes (s4-0 arg1) + (let ((s3-0 (-> arg0 branch-array s4-0))) + (set-default-density-speed-and-width s3-0) + (set! (-> s3-0 src-node) arg0) + (set! (-> s3-0 dest-node) #f) + ) + ) + 0 + (none) + ) + +;; definition for method 16 of type nav-graph +(defmethod debug-add-node nav-graph ((obj nav-graph) (arg0 int)) + (let ((s4-0 (the-as nav-node #f))) + (let ((s5-0 (-> obj node-count)) + (v1-1 (+ arg0 -1 (-> obj branch-count))) + ) + (when (and (< s5-0 2000) (< v1-1 2500)) + (set! s4-0 (-> obj node-array s5-0)) + (debug-reset-branch-array obj s4-0 arg0) + (set-id-and-link-branches-back s4-0 (the-as uint s5-0)) + (+! (-> obj node-count) 1) + ) + ) + s4-0 + ) + ) + +;; definition for method 17 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod debug-link-node-to-graph nav-graph ((obj nav-graph) (arg0 nav-node)) + (when (> (-> arg0 branch-count) 0) + (let ((a0-1 (-> arg0 branch-array 0)) + (t9-0 (method-of-type nav-branch set-dst-node)) + (a2-0 obj) + (v1-4 (-> obj first-node)) + (a1-1 (the-as nav-node #f)) + ) + (if (and (>= v1-4 0) (< v1-4 (-> a2-0 node-count))) + (set! a1-1 (-> a2-0 node-array v1-4)) + ) + (t9-0 a0-1 a1-1) + ) + (let ((v1-9 (+ (-> arg0 id) -1))) + (when (>= v1-9 (the-as uint (-> obj first-node))) + (let ((v1-11 (-> obj node-array v1-9))) + (set! (-> v1-11 branch-count) 1) + (set-dst-node (-> v1-11 branch-array 0) arg0) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 13 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod nav-graph-method-13 nav-graph ((obj nav-graph) (arg0 int) (arg1 int)) + (when (and (< arg0 (-> obj node-count)) (> arg1 0)) + (let ((s4-1 (min arg1 (- (-> obj node-count) arg0)))) + (dotimes (s3-0 (-> obj node-count)) + (let ((s2-0 (-> obj node-array s3-0))) + (dotimes (s1-0 (-> s2-0 branch-count)) + (let ((v1-9 (nav-graph-method-40 obj (the-as int (-> s2-0 branch-array s1-0 dest-node))))) + (when (and (>= v1-9 arg0) (< v1-9 (+ arg0 s4-1))) + (let ((v1-11 (-> obj node-array v1-9))) + (cond + ((= (-> v1-11 branch-count) 1) + (let ((v1-14 (-> v1-11 branch-array 0 dest-node id))) + (if (or (< v1-14 (the-as uint arg0)) (>= v1-14 (the-as uint (+ arg0 s4-1)))) + (set-dst-node (-> s2-0 branch-array s1-0) (-> obj node-array v1-14)) + (remove-branch-by-idx s2-0 s1-0) + ) + ) + ) + (else + (remove-branch-by-idx s2-0 s1-0) + ) + ) + ) + ) + ) + ) + ) + ) + (dotimes (s3-1 (-> obj node-count)) + (let ((s2-1 (-> obj node-array s3-1))) + (dotimes (s1-1 (-> s2-1 branch-count)) + (let ((v1-28 (nav-graph-method-40 obj (the-as int (-> s2-1 branch-array s1-1 dest-node))))) + (if (>= v1-28 (+ arg0 s4-1)) + (set-dst-node (-> s2-1 branch-array s1-1) (-> obj node-array (- v1-28 s4-1))) + ) + ) + ) + ) + ) + (let ((s3-2 arg0) + (s2-2 (-> obj node-array (+ arg0 s4-1))) + (s1-2 (-> obj node-array arg0)) + ) + (countdown (s0-0 (- (-> obj node-count) (+ arg0 s4-1))) + (mem-copy! (the-as pointer s1-2) (the-as pointer s2-2) 32) + (set-id-and-link-branches-back s1-2 (the-as uint s3-2)) + (&+! s2-2 32) + (&+! s1-2 32) + (+! s3-2 1) + ) + ) + (set! (-> obj node-count) (- (-> obj node-count) s4-1)) + (if (< arg0 (-> obj first-node)) + (set! (-> obj first-node) (- (-> obj first-node) s4-1)) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 14 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod nav-graph-method-14 nav-graph ((obj nav-graph) (arg0 int) (arg1 int)) + (when (and (< arg0 (-> obj node-count)) (> arg1 0)) + (dotimes (s3-0 (-> obj node-count)) + (let ((s2-0 (-> obj node-array s3-0))) + (dotimes (s1-0 (-> s2-0 branch-count)) + (let ((v1-7 (nav-graph-method-40 obj (the-as int (-> s2-0 branch-array s1-0 dest-node))))) + (if (< arg0 v1-7) + (set-dst-node (-> s2-0 branch-array s1-0) (-> obj node-array (+ v1-7 arg1))) + ) + ) + ) + ) + ) + (let* ((s3-1 (+ arg1 -1 (-> obj node-count))) + (s2-1 (-> obj node-array (- s3-1 arg1))) + (s1-1 (-> obj node-array s3-1)) + ) + (countdown (s0-0 (- (-> obj node-count) arg0)) + (mem-copy! (the-as pointer s1-1) (the-as pointer s2-1) 32) + (set-id-and-link-branches-back s1-1 (the-as uint s3-1)) + (set! s2-1 (+ (the-as uint s2-1) -32)) + (set! s1-1 (+ (the-as uint s1-1) -32)) + (+! s3-1 -1) + ) + ) + (+! (-> obj node-count) arg1) + (+! (-> obj first-node) arg1) + (let ((s3-2 (-> obj node-array arg0)) + (s2-2 (-> obj node-array arg0)) + ) + (dotimes (s1-2 arg1) + (mem-copy! (the-as pointer s2-2) (the-as pointer s3-2) 32) + (set-id-and-link-branches-back s2-2 (the-as uint arg0)) + (+! (-> s2-2 position y) (* 8192.0 (the float (+ s1-2 1)))) + (debug-reset-branch-array obj s2-2 1) + (set-dst-node (-> s2-2 branch-array 0) (-> obj node-array (+ arg0 1))) + (&+! s2-2 32) + (+! arg0 1) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 15 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod debug-reset nav-graph ((obj nav-graph)) + (set! (-> obj node-count) 0) + (set! (-> obj branch-count) 0) + (set! (-> obj first-node) 0) + (set! (-> obj patched) #f) + 0 + (none) + ) + +;; definition for method 12 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod nav-graph-method-12 nav-graph ((obj nav-graph)) + (set! (-> obj first-node) (-> obj node-count)) + 0 + (none) + ) + +;; definition for method 28 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod print-selected-nodes nav-graph ((obj nav-graph)) + (let ((s4-0 0) + (s1-0 0) + (v1-0 #f) + (s3-0 0) + (gp-0 0) + ) + (dotimes (s2-0 (-> obj node-count)) + (let* ((a0-2 (-> obj node-array s2-0)) + (s0-1 (logtest? (-> a0-2 flags) (nav-node-flag-byte selected))) + ) + (when s0-1 + (+! gp-0 1) + (if (not v1-0) + (set! s4-0 s2-0) + ) + (set! s1-0 s2-0) + ) + (set! v1-0 (and (not s0-1) v1-0)) + (when (or v1-0 (and s0-1 (= s2-0 (+ (-> obj node-count) -1)))) + (if (> s3-0 0) + (format #t ", ") + ) + (if (= s4-0 s1-0) + (format #t "~d" s4-0) + (format #t "~d-~d" s4-0 s1-0) + ) + (+! s3-0 1) + ) + (set! v1-0 s0-1) + ) + ) + (format #t "~%") + (format #t "~d nodes selected~%" gp-0) + ) + 0 + (none) + ) + +;; definition for method 22 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod select-nodes-in-range nav-graph ((obj nav-graph) (arg0 int) (arg1 int)) + (when (< arg0 (-> obj node-count)) + (let ((v1-3 (min arg1 (+ (-> obj node-count) -1))) + (a2-3 arg0) + ) + (+ (- 1 arg0) v1-3) + (while (>= v1-3 a2-3) + (let ((a1-4 (-> obj node-array a2-3))) + (logior! (-> a1-4 flags) (nav-node-flag-byte selected)) + ) + (+! a2-3 1) + ) + ) + ) + (print-selected-nodes obj) + 0 + (none) + ) + +;; definition for method 23 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod deselect-nodes-in-range nav-graph ((obj nav-graph) (arg0 int) (arg1 int)) + (when (< arg0 (-> obj node-count)) + (let ((v1-3 (min arg1 (+ (-> obj node-count) -1))) + (a2-3 arg0) + ) + (+ (- 1 arg0) v1-3) + (while (>= v1-3 a2-3) + (let ((a1-4 (-> obj node-array a2-3))) + (logclear! (-> a1-4 flags) (nav-node-flag-byte selected)) + ) + (+! a2-3 1) + ) + ) + ) + (print-selected-nodes obj) + 0 + (none) + ) + +;; definition for method 24 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod toggle-select-nodes-in-range nav-graph ((obj nav-graph) (arg0 int) (arg1 int)) + (when (< arg0 (-> obj node-count)) + (let ((v1-3 (min arg1 (+ (-> obj node-count) -1))) + (a2-3 arg0) + ) + (+ (- 1 arg0) v1-3) + (while (>= v1-3 a2-3) + (let ((a1-4 (-> obj node-array a2-3))) + (logxor! (-> a1-4 flags) (nav-node-flag-byte selected)) + ) + (+! a2-3 1) + ) + ) + ) + (print-selected-nodes obj) + 0 + (none) + ) + +;; definition for method 25 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod select-nodes-in-level nav-graph ((obj nav-graph) (arg0 symbol) (arg1 symbol)) + (dotimes (v1-0 (-> obj node-count)) + (let* ((a3-1 (-> obj node-array v1-0)) + (t0-2 (= (-> a3-1 level) arg0)) + ) + (case arg1 + (('set) + (logclear! (-> a3-1 flags) (nav-node-flag-byte selected)) + (if t0-2 + (logior! (-> a3-1 flags) (nav-node-flag-byte selected)) + ) + ) + (('and) + (if (not t0-2) + (logclear! (-> a3-1 flags) (nav-node-flag-byte selected)) + ) + ) + (('or) + (if t0-2 + (logior! (-> a3-1 flags) (nav-node-flag-byte selected)) + ) + ) + ) + ) + ) + (print-selected-nodes obj) + 0 + (none) + ) + +;; definition for method 26 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod select-nodes-by-nav-mesh-id nav-graph ((obj nav-graph) (arg0 int) (arg1 symbol)) + (dotimes (v1-0 (-> obj node-count)) + (let* ((a3-1 (-> obj node-array v1-0)) + (t0-2 (= (-> a3-1 nav-mesh-id) arg0)) + ) + (case arg1 + (('set) + (logclear! (-> a3-1 flags) (nav-node-flag-byte selected)) + (if t0-2 + (logior! (-> a3-1 flags) (nav-node-flag-byte selected)) + ) + ) + (('and) + (if (not t0-2) + (logclear! (-> a3-1 flags) (nav-node-flag-byte selected)) + ) + ) + (('or) + (if t0-2 + (logior! (-> a3-1 flags) (nav-node-flag-byte selected)) + ) + ) + ) + ) + ) + (print-selected-nodes obj) + 0 + (none) + ) + +;; definition for method 27 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod select-nodes-by-flags nav-graph ((obj nav-graph) (arg0 nav-node-flag-byte) (arg1 nav-node-flag-byte) (arg2 symbol)) + (dotimes (v1-0 (-> obj node-count)) + (let* ((t0-1 (-> obj node-array v1-0)) + (t1-3 (= (logand (-> t0-1 flags) arg1) arg0)) + ) + (case arg2 + (('set) + (logclear! (-> t0-1 flags) (nav-node-flag-byte selected)) + (if t1-3 + (logior! (-> t0-1 flags) (nav-node-flag-byte selected)) + ) + ) + (('and) + (if (not t1-3) + (logclear! (-> t0-1 flags) (nav-node-flag-byte selected)) + ) + ) + (('or) + (if t1-3 + (logior! (-> t0-1 flags) (nav-node-flag-byte selected)) + ) + ) + ) + ) + ) + (print-selected-nodes obj) + 0 + (none) + ) + +;; definition for method 29 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod assign-selected-nodes-to-level nav-graph ((obj nav-graph) (arg0 symbol)) + (dotimes (v1-0 (-> obj node-count)) + (let ((a2-1 (-> obj node-array v1-0))) + (if (logtest? (-> a2-1 flags) (nav-node-flag-byte selected)) + (set! (-> a2-1 level) arg0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 30 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod assign-selected-nodes-to-nav-mesh nav-graph ((obj nav-graph) (arg0 uint)) + (dotimes (v1-0 (-> obj node-count)) + (let ((a2-1 (-> obj node-array v1-0))) + (if (logtest? (-> a2-1 flags) (nav-node-flag-byte selected)) + (set! (-> a2-1 nav-mesh-id) arg0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 31 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod set-radius-of-selected-nodes nav-graph ((obj nav-graph) (arg0 float)) + (dotimes (s4-0 (-> obj node-count)) + (let ((a0-2 (-> obj node-array s4-0))) + (if (logtest? (-> a0-2 flags) (nav-node-flag-byte selected)) + (set-radius a0-2 arg0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 35 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod or-flags-of-selected-nodes nav-graph ((obj nav-graph) (arg0 nav-node-flag-byte)) + (dotimes (v1-0 (-> obj node-count)) + (let ((a2-1 (-> obj node-array v1-0))) + (if (logtest? (-> a2-1 flags) (nav-node-flag-byte selected)) + (logior! (-> a2-1 flags) arg0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 36 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod and-flags-of-selected-nodes nav-graph ((obj nav-graph) (arg0 nav-node-flag-byte)) + (let ((v1-0 (lognot arg0))) + (dotimes (a1-1 (-> obj node-count)) + (let ((a2-1 (-> obj node-array a1-1))) + (if (logtest? (-> a2-1 flags) (nav-node-flag-byte selected)) + (logand! (-> a2-1 flags) v1-0) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 32 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod set-speed-limit-of-selected nav-graph ((obj nav-graph) (arg0 float)) + (dotimes (s4-0 (-> obj node-count)) + (let ((s3-0 (-> obj node-array s4-0))) + (when (logtest? (-> s3-0 flags) (nav-node-flag-byte selected)) + (dotimes (s2-0 (-> s3-0 branch-count)) + (set-speed-limit (-> s3-0 branch-array s2-0) arg0) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 33 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod set-density-of-selected nav-graph ((obj nav-graph) (arg0 float)) + (dotimes (s4-0 (-> obj node-count)) + (let ((s3-0 (-> obj node-array s4-0))) + (when (logtest? (-> s3-0 flags) (nav-node-flag-byte selected)) + (dotimes (s2-0 (-> s3-0 branch-count)) + (set-density (-> s3-0 branch-array s2-0) arg0) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 34 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod set-width-of-selected nav-graph ((obj nav-graph) (arg0 float)) + (dotimes (s4-0 (-> obj node-count)) + (let ((s3-0 (-> obj node-array s4-0))) + (when (logtest? (-> s3-0 flags) (nav-node-flag-byte selected)) + (dotimes (s2-0 (-> s3-0 branch-count)) + (set-width (-> s3-0 branch-array s2-0) arg0) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 37 of type nav-graph +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod offset-pos-of-selected nav-graph ((obj nav-graph) (arg0 vector)) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (dotimes (s3-0 (-> obj node-count)) + (let ((a0-2 (-> obj node-array s3-0))) + (when (logtest? (-> a0-2 flags) (nav-node-flag-byte selected)) + (let ((a2-0 a0-2) + (v1-4 s4-0) + ) + (set! (-> v1-4 quad) (-> a2-0 position quad)) + (set! (-> v1-4 w) 1.0) + ) + (vector+! s4-0 s4-0 arg0) + (set-pos-xyz a0-2 s4-0) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 38 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod nav-graph-method-38 nav-graph ((obj nav-graph)) + (let ((s5-0 (new 'stack-no-clear 'vehicle-controller)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (dotimes (s3-0 (-> obj node-count)) + (let ((s2-0 (-> obj node-array s3-0))) + (when (and (logtest? (-> s2-0 flags) (nav-node-flag-byte selected)) (= (-> s2-0 branch-count) 1)) + (let ((a1-0 (-> s2-0 branch-array 0))) + (-> a1-0 dest-node) + (vehicle-controller-method-13 s5-0 a1-0 (-> s2-0 position)) + ) + (vehicle-controller-method-11 s5-0) + (vector-! s4-0 (-> s5-0 target-point) (-> s2-0 position)) + (set! (-> s4-0 y) 0.0) + (vector-normalize! s4-0 1.0) + (set-angle-from-heading s2-0 s4-0) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 9 of type nav-graph +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw-nodes nav-graph ((obj nav-graph)) + (let ((s5-0 (new 'stack-no-clear 'matrix))) + (dotimes (s4-0 (-> obj node-count)) + (let ((s3-0 (-> obj node-array s4-0))) + (when (not (logtest? (-> s3-0 flags) (nav-node-flag-byte hidden))) + (debug-draw s3-0) + (let ((a1-0 s3-0) + (v1-6 (-> s5-0 vector)) + ) + (set! (-> v1-6 0 quad) (-> a1-0 position quad)) + (set! (-> v1-6 0 w) 1.0) + ) + (dotimes (s2-0 (-> s3-0 branch-count)) + (let ((v1-9 (-> s3-0 branch-array s2-0 dest-node))) + (when v1-9 + (let ((a2-0 v1-9) + (a0-7 (-> s5-0 vector 1)) + ) + (set! (-> a0-7 quad) (-> a2-0 position quad)) + (set! (-> a0-7 w) 1.0) + ) + (vector-! (-> s5-0 vector 2) (-> s5-0 vector 1) (the-as vector (-> s5-0 vector))) + (let* ((f0-2 (vector-length (-> s5-0 vector 2))) + (f1-2 (fmax (* 0.75 f0-2) (+ -8192.0 f0-2))) + ) + (vector-float*! (-> s5-0 vector 2) (-> s5-0 vector 2) (/ f1-2 f0-2)) + ) + (vector+! (-> s5-0 trans) (the-as vector (-> s5-0 vector)) (-> s5-0 vector 2)) + (add-debug-line + #t + (bucket-id debug2) + (the-as vector (-> s5-0 vector)) + (-> s5-0 trans) + (cond + ((= (-> v1-9 id) #xffff) + *color-dark-blue* + ) + ((logtest? (-> s3-0 flags) (nav-node-flag-byte pedestrian)) + *color-dark-red* + ) + (else + *color-dark-green* + ) + ) + #f + *color-white* + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 10 of type nav-graph +;; INFO: Used lq/sq +;; WARN: Return type mismatch nav-node vs none. +(defmethod nav-graph-method-10 nav-graph ((obj nav-graph) (arg0 vector) (arg1 int)) + (let* ((gp-0 (the-as nav-node #f)) + (f0-0 409600000.0) + (f30-0 (* f0-0 f0-0)) + ) + (dotimes (s2-0 (-> obj node-count)) + (let ((s1-0 (-> obj node-array s2-0)) + (a1-1 (new 'stack-no-clear 'vector)) + ) + (when (and (not (logtest? (-> s1-0 flags) (nav-node-flag-byte hidden))) + (or (not arg1) (and arg1 (logtest? (-> s1-0 flags) (nav-node-flag-byte selected)))) + ) + (let ((a2-1 s1-0) + (v1-8 a1-1) + ) + (set! (-> v1-8 quad) (-> a2-1 position quad)) + (set! (-> v1-8 w) 1.0) + ) + (let ((f0-3 (vector-vector-distance-squared arg0 a1-1))) + (when (< f0-3 f30-0) + (set! gp-0 s1-0) + (set! f30-0 f0-3) + ) + ) + ) + ) + ) + ) + (none) + ) + +;; definition for method 21 of type nav-graph +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod move-selected-to-height-map-height nav-graph ((obj nav-graph)) + (dotimes (s5-0 (-> obj node-count)) + (let ((s4-0 (-> obj node-array s5-0)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (when (and (not (logtest? (-> s4-0 flags) (nav-node-flag-byte hidden))) + (not (logtest? (-> s4-0 flags) (nav-node-flag-byte pedestrian))) + (logtest? (-> s4-0 flags) (nav-node-flag-byte selected)) + ) + (let ((a1-0 s4-0) + (v1-8 s3-0) + ) + (set! (-> v1-8 quad) (-> a1-0 position quad)) + (set! (-> v1-8 w) 1.0) + ) + (let ((a1-3 s3-0)) + (set! (-> s3-0 y) (get-height-at-point *traffic-height-map* a1-3)) + ) + (set-pos-xyz s4-0 s3-0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 39 of type nav-graph +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod nav-graph-method-39 nav-graph ((obj nav-graph)) + (local-vars (sv-80 entity-nav-mesh) (sv-96 entity-nav-mesh)) + (dotimes (s5-0 (-> obj node-count)) + (let ((s4-0 (-> obj node-array s5-0)) + (s3-0 (new 'stack-no-clear 'vector)) + ) + (let ((a1-0 s4-0) + (v1-1 s3-0) + ) + (set! (-> v1-1 quad) (-> a1-0 position quad)) + (set! (-> v1-1 w) 1.0) + ) + (when (logtest? (-> s4-0 flags) (nav-node-flag-byte pedestrian)) + (dotimes (s2-0 (-> *level* length)) + (let ((v1-8 (-> *level* level s2-0))) + (when (= (-> v1-8 status) 'active) + (let ((s1-0 (-> v1-8 bsp nav-meshes))) + (when (nonzero? s1-0) + (dotimes (s0-0 (-> s1-0 length)) + (set! sv-80 (-> s1-0 s0-0)) + (-> sv-80 aid) + (set! sv-96 sv-80) + (let ((v1-16 (if (type? sv-96 entity-nav-mesh) + sv-96 + ) + ) + ) + (when v1-16 + (let ((a0-10 (-> v1-16 nav-mesh)) + (a1-5 (new 'stack-no-clear 'nav-find-poly-parms)) + ) + (vector-! (-> a1-5 point) s3-0 (-> a0-10 bounds)) + (set! (-> a1-5 y-threshold) 40960.0) + (set! (-> a1-5 ignore) (the-as uint 2)) + (if (find-poly-containing-point-local a0-10 a1-5) + (set! (-> s4-0 nav-mesh-id) (-> sv-80 aid)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 19 of type nav-graph +(defmethod nav-graph-method-19 nav-graph ((obj nav-graph) (arg0 int) (arg1 int) (arg2 int) (arg3 int) (arg4 int) (arg5 int)) + (let ((gp-0 (-> obj node-array arg0)) + (s0-0 (-> obj node-array arg1)) + (s4-0 (-> obj node-array arg2)) + (s2-0 (-> obj node-array arg3)) + (s1-0 (-> obj node-array arg4)) + (s3-0 (-> obj node-array arg5)) + ) + (debug-reset-branch-array obj s0-0 2) + (set-dst-node (-> s0-0 branch-array 0) s4-0) + (set-dst-node (-> s0-0 branch-array 1) s1-0) + (debug-reset-branch-array obj s2-0 2) + (set-dst-node (-> s2-0 branch-array 0) s1-0) + (set-dst-node (-> s2-0 branch-array 1) gp-0) + (debug-reset-branch-array obj s3-0 2) + (set-dst-node (-> s3-0 branch-array 0) gp-0) + (set-dst-node (-> s3-0 branch-array 1) s4-0) + ) + (none) + ) + +;; definition for method 40 of type nav-graph +(defmethod nav-graph-method-40 nav-graph ((obj nav-graph) (arg0 int)) + -1 + (shr (- arg0 (the-as int (-> obj node-array 0))) 5) + ) + +;; definition for method 20 of type nav-graph +(defmethod nav-graph-method-20 nav-graph ((obj nav-graph) (arg0 int) (arg1 int)) + (let ((gp-0 (-> obj node-array arg0)) + (s5-0 (-> obj node-array arg1)) + ) + (debug-reset-branch-array obj gp-0 1) + (set-dst-node (-> gp-0 branch-array 0) s5-0) + ) + (none) + ) + +;; definition for method 11 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod nav-graph-method-11 nav-graph ((obj nav-graph)) + (format #t "(define *traffic-nav-graph*~%") + (format #t " (new-nav-graph~%") + (format #t " :node-list (~%") + (dotimes (s5-0 (-> obj node-count)) + (let ((a0-5 (-> obj node-array s5-0))) + (set! (-> a0-5 id) (the-as uint s5-0)) + (debug-print a0-5 #t " ") + ) + ) + (format #t "~T~T )~%") + (format #t " )~%") + (format #t " )~%") + 0 + (none) + ) + +;; definition for method 42 of type nav-graph +;; WARN: Return type mismatch int vs none. +(defmethod patch-nodes nav-graph ((obj nav-graph)) + "Patch nodes. Node pointers are stored as indices into arrays to be allocated on the level heap +and patched at runtime after loading." + (when (not (-> obj patched)) + (set! (-> obj patched) #t) + (let ((s5-0 0)) + (dotimes (s4-0 (-> obj node-count)) + (let ((s3-0 (-> obj node-array s4-0))) + (dotimes (s2-0 (-> s3-0 branch-count)) + (let ((s1-0 (-> s3-0 branch-array s2-0))) + (+! s5-0 1) + (set-src-node s1-0 s3-0) + (let ((v1-7 (the-as object (-> s1-0 dest-node)))) + (set-dst-node s1-0 (-> obj node-array (the-as uint v1-7))) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 43 of type nav-graph +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +;; WARN: Function (method 43 nav-graph) has a return type of none, but the expression builder found a return statement. +(defmethod copy-to-mysql-graph nav-graph ((obj nav-graph) (arg0 mysql-nav-graph) (arg1 string)) + (set! (-> arg0 node-array length) 0) + (set! (-> arg0 edge-array length) 0) + (set! (-> arg0 visnode-array length) 0) + (let ((s3-0 (clear *temp-string*))) + (format s3-0 "select nav_graph_id from nav_graph where name='~S'" arg1) + (let ((a2-2 (sql-query s3-0))) + (when (!= (-> a2-2 error) 'select) + (format 0 "ERROR: sql: select error ~A for ~A~%" a2-2 obj) + (return #f) + ) + (set! (-> arg0 nav_graph_id) (the-as uint (string->int (-> a2-2 data 0)))) + ) + ) + (dotimes (v1-7 (-> obj node-count)) + (let ((a1-6 (-> arg0 node-array data (-> arg0 node-array length))) + (a0-11 (-> obj node-array v1-7)) + ) + (logior! (-> a1-6 mysql-save-flag) (mysql-save-flag insert)) + (set! (-> a1-6 runtime-id) (-> a0-11 id)) + (set! (-> a1-6 nav_graph_id) (-> arg0 nav_graph_id)) + (let ((t0-0 a0-11) + (a2-8 (-> a1-6 position)) + ) + (set! (-> a2-8 quad) (-> t0-0 position quad)) + (set! (-> a2-8 w) 1.0) + ) + (set! (-> a1-6 level_name) (-> a0-11 level)) + (set! (-> a1-6 angle) (the float (-> a0-11 angle))) + (let ((a2-13 a0-11)) + (set! (-> a1-6 radius) (* 1024.0 (the float (-> a2-13 radius)))) + ) + (set! (-> a1-6 nav_node_flag) (the-as nav-node-flag (-> a0-11 flags))) + (set! (-> a1-6 nav_mesh_id) (-> a0-11 nav-mesh-id)) + (+! (-> arg0 node-array length) 1) + (dotimes (a1-10 (-> a0-11 branch-count)) + (let ((a2-22 (-> arg0 edge-array data (-> arg0 edge-array length))) + (a3-8 (-> a0-11 branch-array a1-10)) + ) + (logior! (-> a2-22 mysql-save-flag) (mysql-save-flag insert)) + (set! (-> a2-22 nav_graph_id) (-> arg0 nav_graph_id)) + (set! (-> a2-22 runtime-id) (the-as uint (-> arg0 edge-array length))) + (set! (-> a2-22 runtime-node-id-1) (the-as int (-> a0-11 id))) + (set! (-> a2-22 runtime-node-id-2) (the-as int (-> a3-8 dest-node id))) + (set! (-> a2-22 directionality) (nav-directionality default)) + (let ((t0-12 a3-8)) + (set! (-> a2-22 speed_limit) (* 1024.0 (the float (-> t0-12 speed-limit)))) + ) + (let ((t0-15 a3-8)) + (set! (-> a2-22 density) (* 0.0078125 (the float (-> t0-15 density)))) + ) + (set! (-> a2-22 nav_clock_mask) (the-as nav-clock-mask (-> a3-8 clock-mask))) + (set! (-> a2-22 nav_clock_type) (the-as nav-clock-type (-> a3-8 clock-type))) + (set! (-> a2-22 width) (* 256.0 (the float (-> a3-8 width)))) + ) + (+! (-> arg0 edge-array length) 1) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 0 of type nav-graph +;; WARN: Return type mismatch object vs nav-graph. +(defmethod new nav-graph ((allocation symbol) (type-to-make type) (arg0 int) (arg1 int) (arg2 int) (arg3 uint)) + (let ((s1-0 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size)))))) + (when (zero? (the-as nav-graph s1-0)) + (set! s1-0 0) + (goto cfg-4) + ) + (set! (-> (the-as nav-graph s1-0) node-count) arg0) + (set! (-> (the-as nav-graph s1-0) branch-count) arg1) + (set! (-> (the-as nav-graph s1-0) link-count) arg2) + (set! (-> (the-as nav-graph s1-0) node-array) + (the-as (inline-array nav-node) (malloc allocation (* arg0 32))) + ) + (set! (-> (the-as nav-graph s1-0) branch-array) + (the-as (inline-array nav-branch) (malloc allocation (* arg1 16))) + ) + (set! (-> (the-as nav-graph s1-0) link-array) + (the-as (inline-array nav-graph-link) (malloc allocation (* 48 arg2))) + ) + (set! (-> (the-as nav-graph s1-0) first-node) 0) + (set! (-> (the-as nav-graph s1-0) patched) #f) + (set! (-> (the-as nav-graph s1-0) id) arg3) + (label cfg-4) + (the-as nav-graph s1-0) + ) + ) + +;; definition for method 44 of type nav-graph +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod from-editor nav-graph ((obj nav-graph) (arg0 mysql-nav-graph) (arg1 symbol)) + (local-vars + (v1-4 symbol) + (v1-6 symbol) + (v1-37 symbol) + (sv-16 int) + (sv-32 int) + (sv-48 mysql-nav-node) + (sv-64 nav-branch) + (sv-80 nav-graph-link) + (sv-96 nav-node) + (sv-112 int) + ) + (set! (-> obj node-count) 0) + (set! (-> obj branch-count) 0) + (set! (-> obj link-count) 0) + (mysql-nav-graph-method-20 arg0) + (let ((s5-0 0)) + (let ((s2-0 0)) + (b! #t cfg-34 :delay (nop!)) + (label cfg-1) + (let ((s0-0 (-> arg0 node-array data s2-0))) + (let ((a0-3 (= arg1 #f))) + (b! a0-3 cfg-4 :likely-delay (set! v1-4 a0-3)) + ) + (set! v1-4 (= arg1 (-> s0-0 level_name))) + (label cfg-4) + (b! (not v1-4) cfg-7 :likely-delay (set! v1-6 v1-4)) + (set! v1-6 (zero? (logand (-> s0-0 mysql-save-flag) (mysql-save-flag delete)))) + (label cfg-7) + (b! (not v1-6) cfg-27 :delay (nop!)) + (set! sv-16 (temp-edge-size s0-0)) + (let ((s1-0 (debug-add-node obj sv-16))) + (b! (not s1-0) cfg-36 :delay (nop!)) + (set! (-> s1-0 id) (the-as uint (if arg1 + (-> s0-0 level-node-index) + s2-0 + ) + ) + ) + (set! (-> s1-0 flags) (the-as nav-node-flag-byte (-> s0-0 nav_node_flag))) + (set-pos-xyz s1-0 (-> s0-0 position)) + (set-angle s1-0 (-> s0-0 angle)) + (set-radius s1-0 (-> s0-0 radius)) + (set! (-> s1-0 level) (-> s0-0 level_name)) + (set! (-> s1-0 nav-mesh-id) (-> s0-0 nav_mesh_id)) + (when (!= (-> obj branch-array s5-0) (-> s1-0 branch-array 0)) + (format 0 "nav-graph::from-editor: ERROR something went awry in allocate-branches~%") + (break!) + 0 + ) + (let ((s0-1 (the-as object (-> s0-0 temp-edge-list)))) + (set! sv-32 sv-16) + (b! #t cfg-25 :delay (nop!)) + (label cfg-15) + (set! sv-32 (+ sv-32 -1)) + (set! sv-64 (-> obj branch-array s5-0)) + (set-src-node sv-64 s1-0) + (set-speed-limit sv-64 (-> (the-as mysql-nav-edge s0-1) speed_limit)) + (set-density sv-64 (-> (the-as mysql-nav-edge s0-1) density)) + (set-width sv-64 (-> (the-as mysql-nav-edge s0-1) width)) + (set! (-> sv-64 clock-type) (the-as nav-branch-clock-type (-> (the-as mysql-nav-edge s0-1) nav_clock_type))) + (set! (-> sv-64 clock-mask) (the-as nav-branch-clock-mask (-> (the-as mysql-nav-edge s0-1) nav_clock_mask))) + (set! sv-48 (-> arg0 node-array data (-> (the-as mysql-nav-edge s0-1) runtime-node-id-2))) + (let ((a0-23 (= arg1 #f))) + (b! a0-23 cfg-18 :likely-delay (set! v1-37 a0-23)) + ) + (set! v1-37 (= arg1 (-> sv-48 level_name))) + (label cfg-18) + (b! (not v1-37) cfg-23 :delay (nop!)) + (let ((t9-11 (method-of-type nav-branch set-dst-node)) + (a1-11 (-> obj node-array (if arg1 + (-> sv-48 level-node-index) + (-> (the-as mysql-nav-edge s0-1) runtime-node-id-2) + ) + ) + ) + ) + (t9-11 sv-64 a1-11) + ) + (b! #t cfg-24 :delay (nop!)) + (label cfg-23) + (set-dst-node sv-64 (the-as nav-node #f)) + (set! sv-112 (-> obj link-count)) + (set! sv-80 (-> obj link-array sv-112)) + (set! (-> sv-80 dest-graph-id) (-> (lookup-level-info2 arg0 sv-48 #f) level-id)) + (set! (-> sv-80 src-branch-id) (the-as uint s5-0)) + (set! (-> sv-80 dest-node-id) (the-as uint (-> sv-48 level-node-index))) + (set! (-> sv-80 dest-graph) #f) + (set! sv-96 (-> sv-80 dummy-node)) + (set! (-> sv-96 id) (the-as uint #xffff)) + (set! (-> sv-96 flags) (the-as nav-node-flag-byte (-> sv-48 nav_node_flag))) + (set-pos-xyz sv-96 (-> sv-48 position)) + (set-angle sv-96 (-> sv-48 angle)) + (set-radius sv-96 (-> sv-48 radius)) + (set! (-> sv-96 level) (-> sv-48 level_name)) + (set! (-> sv-96 nav-mesh-id) (-> sv-48 nav_mesh_id)) + (set-dst-node sv-64 (-> sv-80 dummy-node)) + (format #t "outputting link ~d~%" sv-112) + (+! (-> obj link-count) 1) + (label cfg-24) + (+! s5-0 1) + (set! s0-1 (-> (the-as mysql-nav-edge s0-1) temp-next-edge)) + ) + ) + (label cfg-25) + (b! (nonzero? sv-32) cfg-15 :delay (nop!)) + (b! #t cfg-33 :delay (nop!)) + (label cfg-27) + (let ((v1-78 (the-as object (-> s0-0 temp-edge-list)))) + (b! #t cfg-31 :delay (nop!)) + (label cfg-28) + (when (= arg1 (-> arg0 node-array data (-> (the-as mysql-nav-edge v1-78) runtime-node-id-2) level_name)) + ) + (set! v1-78 (-> (the-as mysql-nav-edge v1-78) temp-next-edge)) + (label cfg-31) + (b! v1-78 cfg-28 :delay (nop!)) + ) + ) + (label cfg-33) + (+! s2-0 1) + (label cfg-34) + (b! (< s2-0 (-> arg0 node-array length)) cfg-1) + ) + (format #t "branch-count ~d~%" s5-0) + ) + (set! (-> obj patched) #t) + (label cfg-36) + 0 + (none) + ) + +;; definition for function make-nav-graph +;; WARN: Return type mismatch nav-graph vs none. +(defun make-nav-graph ((arg0 mysql-nav-graph) (arg1 symbol)) + (mysql-nav-graph-method-20 arg0) + (let ((s4-0 (the-as nav-graph #f)) + (v1-2 (the-as mysql-nav-graph-level-info #f)) + ) + (dotimes (a0-2 (-> arg0 level-info-array-length)) + (let ((a1-3 (-> arg0 level-info-array a0-2))) + (if (= (-> a1-3 level) arg1) + (set! v1-2 a1-3) + ) + ) + ) + (when v1-2 + (set! s4-0 + (new 'debug 'nav-graph (-> v1-2 node-count) (-> v1-2 branch-count) (-> v1-2 to-link-count) (-> v1-2 level-id)) + ) + (if s4-0 + (from-editor s4-0 arg0 arg1) + ) + ) + ) + (none) + ) + + + + diff --git a/test/decompiler/reference/jak2/levels/city/common/pilot-states_REF.gc b/test/decompiler/reference/jak2/levels/city/common/pilot-states_REF.gc new file mode 100644 index 0000000000..25f39b0cc6 --- /dev/null +++ b/test/decompiler/reference/jak2/levels/city/common/pilot-states_REF.gc @@ -0,0 +1,1072 @@ +;;-*-Lisp-*- +(in-package goal) + +;; failed to figure out what this is: +(defstate target-pilot-start (target) + :event target-pilot-handler + :exit (the-as (function none :behavior target) target-pilot-exit) + :code (behavior ((arg0 handle) (arg1 symbol) (arg2 symbol)) + (target-pilot-init arg0 arg2) + (suspend) + (remove-exit) + (if arg1 + (go target-pilot-stance) + (go target-pilot-get-on) + ) + (none) + ) + :post target-post + ) + +;; definition for function target-pilot-bike-anim-loop +;; WARN: Return type mismatch symbol vs none. +;; WARN: new jak 2 until loop case, check carefully +(defbehavior target-pilot-bike-anim-loop target () + (ja-channel-push! 3 (seconds 0.1)) + (ja :group! (-> self draw art-group data 210)) + (ja :chan 1 :group! (-> self draw art-group data 209)) + (ja :chan 2 :group! (-> self draw art-group data 214)) + (until #f + (let ((gp-0 (-> self pilot))) + (let ((f30-0 (* 5.0 (- 1.0 (-> gp-0 left-right-interp))))) + (ja :num-func num-func-identity :frame-num (ja-aframe f30-0 0)) + (let ((f0-3 (fmax 0.0 (fmin 1.0 (* 0.5 (+ 1.0 (* 1.42 (+ -0.3 (-> gp-0 front-back-interp)))))))) + (s5-1 (-> self skel root-channel 1)) + ) + (set! (-> s5-1 frame-interp 1) f0-3) + (set! (-> s5-1 frame-interp 0) f0-3) + (set! (-> s5-1 num-func) num-func-identity) + (set! (-> s5-1 frame-num) (ja-aframe f30-0 1)) + ) + ) + (let ((f0-6 (* 5.0 (- 1.0 (-> gp-0 up-down-interp)))) + (s5-2 (-> self skel root-channel 2)) + ) + (let ((f1-7 (fabs (-> gp-0 up-down-interp)))) + (set! (-> s5-2 frame-interp 1) f1-7) + (set! (-> s5-2 frame-interp 0) f1-7) + ) + (set! (-> s5-2 num-func) num-func-identity) + (set! (-> s5-2 frame-num) (ja-aframe f0-6 2)) + ) + ) + (can-play-stance-amibent?) + (suspend) + ) + #f + (none) + ) + +;; definition for function target-pilot-car-anim-loop +;; WARN: Return type mismatch symbol vs none. +;; WARN: new jak 2 until loop case, check carefully +(defbehavior target-pilot-car-anim-loop target () + (ja-channel-push! 3 (seconds 0.1)) + (ja :group! (-> self draw art-group data 203)) + (ja :chan 1 :group! (-> self draw art-group data 202)) + (ja :chan 2 :group! (-> self draw art-group data 213)) + (until #f + (let ((gp-0 (-> self pilot))) + (let ((f30-0 (* 5.0 (+ 1.0 (-> gp-0 left-right-interp))))) + (ja :num-func num-func-identity :frame-num (ja-aframe f30-0 0)) + (let ((s5-1 (-> self skel root-channel 1))) + (let ((f0-3 (* 0.5 (+ 1.0 (-> gp-0 front-back-interp))))) + (set! (-> s5-1 frame-interp 1) f0-3) + (set! (-> s5-1 frame-interp 0) f0-3) + ) + (set! (-> s5-1 num-func) num-func-identity) + (set! (-> s5-1 frame-num) (ja-aframe f30-0 1)) + ) + ) + (let ((f0-6 (* 10.0 (- 1.0 (-> gp-0 up-down-interp)))) + (s5-2 (-> self skel root-channel 2)) + ) + (let ((f1-7 (fabs (-> gp-0 up-down-interp)))) + (set! (-> s5-2 frame-interp 1) f1-7) + (set! (-> s5-2 frame-interp 0) f1-7) + ) + (set! (-> s5-2 num-func) num-func-identity) + (set! (-> s5-2 frame-num) (ja-aframe f0-6 2)) + ) + ) + (suspend) + ) + #f + (none) + ) + +;; definition for function target-daxter-pilot-car-anim-loop +;; WARN: Return type mismatch symbol vs none. +;; WARN: new jak 2 until loop case, check carefully +(defbehavior target-daxter-pilot-car-anim-loop target () + (ja-channel-push! 3 (seconds 0.1)) + (ja :group! (-> self draw art-group data 453)) + (ja :chan 1 :group! (-> self draw art-group data 452)) + (ja :chan 2 :group! (-> self draw art-group data 454)) + (until #f + (let ((gp-0 (-> self pilot))) + (let ((f30-0 (* 5.0 (+ 1.0 (-> gp-0 left-right-interp))))) + (ja :num-func num-func-identity :frame-num (ja-aframe f30-0 0)) + (let ((s5-1 (-> self skel root-channel 1))) + (let ((f0-3 (* 0.5 (+ 1.0 (-> gp-0 front-back-interp))))) + (set! (-> s5-1 frame-interp 1) f0-3) + (set! (-> s5-1 frame-interp 0) f0-3) + ) + (set! (-> s5-1 num-func) num-func-identity) + (set! (-> s5-1 frame-num) (ja-aframe f30-0 1)) + ) + ) + (let ((f0-6 (* 10.0 (- 1.0 (-> gp-0 up-down-interp)))) + (s5-2 (-> self skel root-channel 2)) + ) + (let ((f1-7 (fabs (-> gp-0 up-down-interp)))) + (set! (-> s5-2 frame-interp 1) f1-7) + (set! (-> s5-2 frame-interp 0) f1-7) + ) + (set! (-> s5-2 num-func) num-func-identity) + (set! (-> s5-2 frame-num) (ja-aframe f0-6 2)) + ) + ) + (suspend) + ) + #f + (none) + ) + +;; definition for function target-pilot-trans +;; INFO: Used lq/sq +;; WARN: Return type mismatch object vs none. +(defbehavior target-pilot-trans target () + (let* ((gp-0 (-> self pilot)) + (s5-0 (handle->process (-> gp-0 vehicle))) + ) + (cond + ((not s5-0) + (ja-channel-set! 0) + (go target-falling #f) + ) + (#t + (let ((s4-0 (new 'stack-no-clear 'inline-array 'vector 10))) + (set! (-> gp-0 accel-array 7 quad) (-> gp-0 accel-array 6 quad)) + (set! (-> gp-0 accel-array 6 quad) (-> gp-0 accel-array 5 quad)) + (set! (-> gp-0 accel-array 5 quad) (-> gp-0 accel-array 4 quad)) + (set! (-> gp-0 accel-array 4 quad) (-> gp-0 accel-array 3 quad)) + (set! (-> gp-0 accel-array 3 quad) (-> gp-0 accel-array 2 quad)) + (set! (-> gp-0 accel-array 2 quad) (-> gp-0 accel-array 1 quad)) + (set! (-> gp-0 accel-array 1 quad) (-> gp-0 accel-array 0 quad)) + (vehicle-method-115 (the-as vehicle s5-0) (the-as vector (-> gp-0 accel-array))) + (vector-reset! (-> s4-0 0)) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (the-as vector (-> gp-0 accel-array)) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 1) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 2) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 3) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 4) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 5) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 6) 1.0) + (vector+float*! (-> s4-0 0) (-> s4-0 0) (-> gp-0 accel-array 7) 1.0) + (vector-float*! (-> s4-0 0) (-> s4-0 0) 0.5) + (matrix-transpose! (the-as matrix (-> s4-0 1)) (-> self node-list data 0 bone transform)) + (vector-rotate*! (-> gp-0 local-accel) (-> s4-0 0) (the-as matrix (-> s4-0 1))) + ) + (vehicle-method-116 (the-as vehicle s5-0) (the-as (pointer vehicle-controls) (-> gp-0 controls))) + (let ((f30-0 (* 182.04445 (* 0.6 (the float (-> self clock frame-counter))))) + (s5-1 (-> gp-0 local-accel)) + ) + (let ((f3-0 + (+ (-> gp-0 controls steering) (* 0.03 (sin f30-0)) (* -1.0 (-> s5-1 x) (-> gp-0 left-right-accel-factor))) + ) + ) + (set! (-> gp-0 left-right-interp) + (fmax + -1.0 + (fmin + 1.0 + (+ (-> gp-0 left-right-interp) (* 8.0 (- f3-0 (-> gp-0 left-right-interp)) (-> self clock seconds-per-frame))) + ) + ) + ) + ) + (let ((f3-4 + (+ (-> gp-0 controls lean-z) (* 0.03 (cos f30-0)) (* -1.0 (-> s5-1 z) (-> gp-0 front-back-accel-factor))) + ) + ) + (set! (-> gp-0 front-back-interp) + (fmax + -1.0 + (fmin + 1.0 + (+ (-> gp-0 front-back-interp) (* 8.0 (- f3-4 (-> gp-0 front-back-interp)) (-> self clock seconds-per-frame))) + ) + ) + ) + ) + (let ((f3-8 (+ (* 0.03 (cos f30-0)) (* -1.0 (-> s5-1 y) (-> gp-0 up-down-accel-factor))))) + (set! (-> gp-0 up-down-interp) + (fmax + -1.0 + (fmin + 1.0 + (+ (-> gp-0 up-down-interp) (* 8.0 (- f3-8 (-> gp-0 up-down-interp)) (-> self clock seconds-per-frame))) + ) + ) + ) + ) + ) + (when (and (-> self next-state) (= (-> self next-state name) 'target-pilot-stance)) + (let* ((v1-67 (-> gp-0 accel-array)) + (f0-27 (+ (* (-> v1-67 0 x) (-> v1-67 0 x)) (* (-> v1-67 0 z) (-> v1-67 0 z)))) + ) + (if (or (and (-> self pilot as-daxter?) (let ((f1-20 1024000.0)) + (< (* f1-20 f1-20) f0-27) + ) + ) + (let ((f1-23 2048000.0)) + (< (* f1-23 f1-23) f0-27) + ) + ) + (go target-pilot-impact) + ) + ) + ) + ) + (else + (go target-pilot-get-off) + ) + ) + ) + (none) + ) + +;; definition for function target-pilot-signal-ready +(defbehavior target-pilot-signal-ready target () + (when (not (logtest? (-> self focus-status) (focus-status pilot-riding))) + (logior! (-> self focus-status) (focus-status pilot-riding)) + (send-event (handle->process (-> self pilot vehicle)) 'pilot-on (-> self pilot seat-index)) + ) + ) + +;; failed to figure out what this is: +(defstate target-pilot-stance (target) + :event target-pilot-handler + :exit (the-as (function none :behavior target) target-pilot-exit) + :trans (behavior () + (target-pilot-trans) + (none) + ) + :code (behavior () + (target-pilot-signal-ready) + (logior! (-> self state-flags) (state-flags sf6)) + (set! (-> self control mod-surface) *pilot-mods*) + (logior! (-> self control status) (collide-status on-surface on-ground)) + (cond + ((-> self pilot as-daxter?) + (target-daxter-pilot-car-anim-loop) + ) + ((zero? (-> self pilot stance)) + (target-pilot-bike-anim-loop) + ) + (else + (target-pilot-car-anim-loop) + ) + ) + (none) + ) + :post (behavior () + (target-pilot-post) + (none) + ) + ) + +;; failed to figure out what this is: +(defstate target-pilot-impact (target) + :event target-pilot-handler + :exit (the-as (function none :behavior target) target-pilot-exit) + :trans (behavior () + (target-pilot-trans) + (none) + ) + :code (behavior () + (local-vars (v1-1 float) (v1-252 int)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (-> self pilot))) + (.lvf vf1 (&-> (-> gp-0 local-accel) 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-1 vf1) + (let ((f0-0 v1-1) + (v1-2 (new 'stack-no-clear 'vector)) + ) + (set! (-> v1-2 quad) (-> gp-0 local-accel quad)) + (set! (-> v1-2 x) (* 4.0 (-> v1-2 x))) + (vector-float*! v1-2 v1-2 (/ 1.0 (sqrtf f0-0))) + (let ((s5-0 (cond + ((< 0.707 (-> v1-2 x)) + 5 + ) + ((< (-> v1-2 x) -0.707) + 4 + ) + ((< 0.707 (-> v1-2 y)) + 3 + ) + ((< (-> v1-2 y) -0.707) + 2 + ) + ((< 0.707 (-> v1-2 z)) + 1 + ) + ((< (-> v1-2 z) -0.707) + 0 + ) + (else + 6 + ) + ) + ) + ) + (cond + ((-> self pilot as-daxter?) + (ja-channel-push! 1 (seconds 0.05)) + (cond + ((= s5-0 4) + (ja-no-eval :group! (-> self draw art-group data 457) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 457)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((= s5-0 5) + (ja-no-eval :group! (-> self draw art-group data 458) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 458)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((zero? s5-0) + (ja-no-eval :group! (-> self draw art-group data 455) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 455)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((= s5-0 1) + (ja-no-eval :group! (-> self draw art-group data 456) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 456)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + (else + (ja-no-eval :group! (-> self draw art-group data 455) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 455)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ) + ) + ((zero? (-> self pilot stance)) + (ja-channel-push! 1 (seconds 0.05)) + (let ((v1-131 s5-0)) + (cond + ((= v1-131 4) + (ja-no-eval :group! (-> self draw art-group data 232) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 232)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((= v1-131 5) + (ja-no-eval :group! (-> self draw art-group data 233) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 233)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((zero? v1-131) + (ja-no-eval :group! (-> self draw art-group data 211) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 211)) frames num-frames) -1))) + :frame-num (ja-aframe 0.0 0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((= v1-131 1) + (ja-no-eval :group! (-> self draw art-group data 212) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 212)) frames num-frames) -1))) + :frame-num (ja-aframe 0.0 0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + (else + (ja-no-eval :group! (-> self draw art-group data 215) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 215)) frames num-frames) -1))) + :frame-num (ja-aframe 0.0 0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ) + ) + ) + ((begin (ja-channel-push! 1 (seconds 0.05)) (set! v1-252 s5-0) (= v1-252 4)) + (ja-no-eval :group! (-> self draw art-group data 234) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 234)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((= v1-252 5) + (ja-no-eval :group! (-> self draw art-group data 235) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 235)) frames num-frames) -1))) + :frame-num 0.0 + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ((zero? v1-252) + (ja-no-eval :group! (-> self draw art-group data 204) + :num! (seek! + (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 204)) frames num-frames) -1)) + 1.3 + ) + :frame-num (ja-aframe 4.0 0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek! max 1.3)) + ) + ) + ((= v1-252 1) + (ja-no-eval :group! (-> self draw art-group data 205) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 205)) frames num-frames) -1))) + :frame-num (ja-aframe 2.0 0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + (else + (ja-no-eval :group! (-> self draw art-group data 208) + :num! (seek! (the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 208)) frames num-frames) -1))) + :frame-num (ja-aframe 0.0 0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek!)) + ) + ) + ) + ) + ) + (.svf (&-> (-> gp-0 accel-array) 0 quad) vf0) + ) + (go target-pilot-stance) + (none) + ) + ) + :post (behavior () + (target-pilot-post) + (none) + ) + ) + +;; failed to figure out what this is: +(let ((v1-9 (copy *empty-mods* 'loading-level))) + (set! (-> v1-9 flags) (surface-flag)) + (set! *pilot-get-on-mods* v1-9) + ) + +;; failed to figure out what this is: +(defstate target-pilot-get-on (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (case event-type + (('end-mode) + (cond + ((logtest? (-> self focus-status) (focus-status pilot-riding)) + (go target-pilot-get-off) + ) + (else + (ja-channel-set! 0) + (go target-falling #f) + ) + ) + ) + (else + (target-standard-event-handler proc arg1 event-type event) + ) + ) + ) + :exit (the-as (function none :behavior target) target-pilot-exit) + :code (behavior () + (set! (-> self focus-status) (logior (focus-status pilot) (-> self focus-status))) + (logior! (-> self state-flags) (state-flags sf6)) + (set! (-> self alt-cam-pos quad) (-> self control camera-pos quad)) + (let ((gp-0 (if (zero? (-> self pilot stance)) + (-> self draw art-group data 201) + (-> self draw art-group data 200) + ) + ) + ) + (ja-channel-set! 1) + (set! (-> self control mod-surface) *pilot-get-on-mods*) + (send-event (ppointer->process (-> self manipy)) 'draw #t) + (set! (-> self neck flex-blend) 0.0) + (set! (-> self control unknown-vector37 quad) (-> self control trans quad)) + (set! (-> self control unknown-vector39 quad) (-> self control quat quad)) + (ja :group! gp-0 + :num! (seek! (the float (+ (-> (the-as art-joint-anim gp-0) frames num-frames) -1))) + :frame-num 0.0 + ) + ) + (until (ja-done? 0) + (let ((f30-0 (sin (lerp-scale 0.0 16384.0 (ja-aframe-num 0) 0.0 10.0)))) + (let ((f28-0 (lerp-scale 0.0 1.0 (ja-aframe-num 0) 0.0 10.0))) + (vector-lerp! + (-> self control trans) + (-> self control unknown-vector37) + (-> self control unknown-vector38) + f30-0 + ) + (set! (-> self control trans y) + (lerp (-> self control unknown-vector37 y) (-> self control unknown-vector38 y) f28-0) + ) + ) + (quaternion-slerp! + (-> self control quat-for-control) + (the-as quaternion (-> self control unknown-vector39)) + (the-as quaternion (-> self control unknown-vector40)) + f30-0 + ) + ) + (rot->dir-targ! (-> self control)) + (if (>= (ja-aframe-num 0) 20.5) + (target-pilot-signal-ready) + ) + (suspend) + (let ((a1-7 (handle->process (-> self pilot vehicle)))) + (if a1-7 + (set! (-> self alt-cam-pos quad) (-> (the-as vehicle a1-7) rbody state position quad)) + ) + ) + (ja :num! (seek!)) + ) + (go target-pilot-stance) + (none) + ) + :post target-no-move-post + ) + +;; failed to figure out what this is: +(let ((v1-12 (copy *forward-jump-mods* 'loading-level))) + (set! (-> v1-12 fric) 0.0) + (set! (-> v1-12 nonlin-fric-dist) 0.0) + (set! (-> v1-12 turnv) 0.0) + (set! (-> v1-12 turnvv) 0.0) + (set! (-> v1-12 tiltv) 131072.0) + (set! (-> v1-12 tiltvf) 30.0) + (set! (-> v1-12 mult-hook) + (the-as + (function surface surface surface int none) + (lambda ((arg0 object) (arg1 object) (arg2 object) (arg3 int)) + (case arg3 + ((1) + (persist-with-delay *setting-control* 'rapid-tracking (seconds 0.05) 'rapid-tracking #f 0.0 0) + ) + ) + (none) + ) + ) + ) + (set! *pilot-get-off-mods* v1-12) + ) + +;; failed to figure out what this is: +(defstate target-pilot-get-off (target) + :event target-standard-event-handler + :exit (the-as (function none :behavior target) target-pilot-exit) + :trans (behavior () + (let ((gp-0 (handle->process (-> self pilot vehicle)))) + (when (not (if (type? gp-0 vehicle) + gp-0 + ) + ) + (ja-channel-set! 0) + (go target-falling #f) + ) + ) + (none) + ) + :code (behavior () + (local-vars (f30-0 float)) + (let ((v1-1 (-> self control root-prim))) + (set! (-> v1-1 prim-core collide-as) (-> self control backup-collide-as)) + (set! (-> v1-1 prim-core collide-with) (-> self control backup-collide-with)) + ) + (logclear! (-> self focus-status) (focus-status pilot-riding)) + (set! (-> self control mod-surface) *pilot-get-off-mods*) + (rot->dir-targ! (-> self control)) + (send-event *camera* 'set-dist #f #f) + (set! (-> self neck flex-blend) 0.0) + 0.0 + (let ((gp-0 (cond + ((zero? (-> self pilot stance)) + (set! f30-0 7.2) + (-> self draw art-group data 216) + ) + (else + (set! f30-0 15.2) + (-> self draw art-group data 199) + ) + ) + ) + ) + (ja-channel-push! 1 (seconds 0.05)) + (ja-no-eval :group! gp-0 :num! (seek! (ja-aframe f30-0 0) 2.0) :frame-num 0.0) + ) + (until (ja-done? 0) + (suspend) + (ja :num! (seek! (ja-aframe f30-0 0) 2.0)) + ) + (let ((v1-29 (camera-matrix)) + (gp-2 (new 'stack-no-clear 'inline-array 'vector 10)) + ) + (set! (-> gp-2 0 quad) (-> v1-29 vector 0 quad)) + (set! (-> gp-2 1 quad) (-> v1-29 vector 2 quad)) + (set! (-> gp-2 1 y) 0.0) + (vector-normalize! (-> gp-2 1) 1.0) + (vector-reset! (-> gp-2 2)) + (vector+float*! + (-> gp-2 2) + (-> gp-2 2) + (-> gp-2 0) + (* 16384.0 (analog-input (the-as int (-> *cpad-list* cpads 0 leftx)) 128.0 48.0 110.0 -1.0)) + ) + (vector+float*! + (-> gp-2 2) + (-> gp-2 2) + (-> gp-2 1) + (* 16384.0 (analog-input (the-as int (-> *cpad-list* cpads 0 lefty)) 128.0 48.0 110.0 -1.0)) + ) + (vector+! (-> self control transv) (-> self control transv) (-> gp-2 2)) + ) + (go target-jump 10240.0 10240.0 *pilot-get-off-mods*) + (none) + ) + :post target-pilot-post + ) + +;; failed to figure out what this is: +(defstate target-pilot-grab (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (cond + ((and (= event-type 'query) (= (-> event param 0) 'mode)) + (-> self state name) + ) + (else + (case event-type + (('end-mode) + (go target-pilot-stance) + ) + (('clone-anim) + (go target-pilot-clone-anim (process->handle (the-as process (-> event param 0)))) + ) + (('vehicle-crash) + (go target-grab 'stance) + ) + (else + (target-generic-event-handler proc arg1 event-type event) + ) + ) + ) + ) + ) + :enter (behavior () + (set! (-> self control mod-surface) *grab-mods*) + (set! (-> self neck flex-blend) 0.0) + (logior! (-> self state-flags) (state-flags sf2)) + (logior! (-> self focus-status) (focus-status grabbed)) + (none) + ) + :exit (behavior () + (logclear! (-> self state-flags) (state-flags sf2)) + (logclear! (-> self focus-status) (focus-status grabbed)) + (logclear! (-> self water flags) (water-flags jump-out)) + ((-> target-pilot-start exit)) + (none) + ) + :code (behavior () + (until #f + (set-forward-vel 0.0) + (suspend) + ) + #f + (none) + ) + :post target-pilot-post + ) + +;; failed to figure out what this is: +(defstate target-pilot-clone-anim (target) + :event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block)) + (if (and (= event-type 'trans) (= (-> event param 0) 'restore)) + (set! (-> self control unknown-word04) (the-as uint #f)) + ) + ((-> target-pilot-grab event) proc arg1 event-type event) + ) + :enter (-> target-clone-anim enter) + :exit (behavior () + (set! (-> self control draw-offset y) (the-as float (-> self control unknown-word04))) + (set! (-> self control cspace-offset y) (-> self control draw-offset y)) + (send-event (ppointer->process (-> self sidekick)) 'matrix #f) + ((-> target-clone-anim exit)) + ((-> target-pilot-start exit)) + (vector-reset! (-> self control transv)) + (none) + ) + :code (behavior ((arg0 handle)) + (set! (-> self control unknown-word04) (the-as uint (-> self control draw-offset y))) + (set! (-> self control draw-offset y) 0.0) + (send-event (ppointer->process (-> self sidekick)) 'matrix 'play-anim) + (clone-anim arg0 #t "") + (go target-pilot-stance) + (none) + ) + :post (behavior () + (vector+! (-> self pilot pilot-trans) (-> self control trans) (-> self control cspace-offset)) + (quaternion-copy! (the-as quaternion (-> self pilot pilot-quat)) (-> self control quat)) + (set! (-> self pilot pilot-scale quad) (-> self control scale quad)) + (target-no-ja-move-post) + (none) + ) + ) + +;; failed to figure out what this is: +(defstate target-pilot-edge-grab (target) + :event (-> target-edge-grab event) + :enter (behavior ((arg0 pilot-edge-grab-info)) + (set! (-> self control status) (collide-status)) + (let ((gp-0 *edge-grab-info*)) + (mem-copy! (the-as pointer (-> gp-0 pilot-edge-grab)) (the-as pointer arg0) 40) + (set! (-> gp-0 pilot-grab-interp) 0.0) + (set! (-> gp-0 pilot-start-grab-pos quad) (-> self control trans quad)) + (set! (-> gp-0 actor-handle) (-> arg0 handle)) + ((-> target-edge-grab enter)) + (let* ((s5-1 (handle->process (-> gp-0 actor-handle))) + (a0-9 (if (type? s5-1 process-focusable) + s5-1 + ) + ) + ) + (set! (-> gp-0 pilot-edge-grab?) + (if (and a0-9 + (< 24576.0 (fabs (- (-> (get-trans (the-as process-focusable a0-9) 0) y) (-> self control trans y)))) + ) + 'target-double-jump + 'target-jump + ) + ) + ) + ) + (none) + ) + :exit (-> target-edge-grab exit) + :trans (-> target-edge-grab trans) + :code (-> target-edge-grab code) + :post target-no-move-post + ) + +;; failed to figure out what this is: +(defstate target-pilot-hit (target) + :event target-generic-event-handler + :exit (behavior () + (if (not (and (-> self next-state) (= (-> self next-state name) 'target-death))) + (logclear! (-> self focus-status) (focus-status dead hit)) + ) + ((-> target-pilot-start exit)) + (none) + ) + :code (behavior ((arg0 symbol) (arg1 attack-info)) + (local-vars (sv-16 attack-info)) + (set! (-> self state-time) (-> self clock frame-counter)) + (set! (-> self neck flex-blend) 0.0) + (set! sv-16 (-> self attack-info)) + (let ((v1-4 sv-16)) + (set! (-> v1-4 attacker) (the-as handle #f)) + (set! (-> v1-4 mode) 'generic) + (set! (-> v1-4 shove-back) 6144.0) + (set! (-> v1-4 shove-up) 4915.2) + (set! (-> v1-4 angle) #f) + (set! (-> v1-4 trans quad) (-> self control trans quad)) + (set! (-> v1-4 control) 0.0) + (set! (-> v1-4 invinc-time) (the-as time-frame (-> *TARGET-bank* hit-invulnerable-timeout))) + (set! (-> v1-4 damage) (-> *FACT-bank* health-default-inc)) + ) + (combine! sv-16 arg1 self) + (pickup-collectable! (-> self fact-override) (pickup-type health) -1000.0 (the-as handle #f)) + (go target-pilot-death (-> sv-16 mode)) + (none) + ) + :post target-no-stick-post + ) + +;; failed to figure out what this is: +(defstate target-pilot-death (target) + :event (-> target-death event) + :exit (behavior () + ((-> target-pilot-start exit)) + ((-> target-death exit)) + (none) + ) + :code (behavior ((arg0 symbol)) + (set! (-> self control unknown-word04) (the-as uint #f)) + (set! (-> self control did-move-to-pole-or-max-jump-height) + (the-as float (send-event (handle->process (-> self attack-info attacker)) 'target 'die arg0)) + ) + (set! (-> self neck flex-blend) 0.0) + (target-timed-invulnerable-off self 0) + (case arg0 + (('bot) + (set-setting! 'process-mask 'set 0 (process-mask platform projectile death)) + ) + (('endlessfall 'instant-death 'lava 'dark-eco-pool 'melt 'explode 'grenade) + (set-setting! 'process-mask 'set 0 (process-mask enemy platform projectile death)) + ) + (else + (set-setting! 'process-mask 'set 0 (process-mask enemy platform projectile death)) + (when (using-gun? self) + (send-event (ppointer->process (-> self gun gun)) 'die) + (target-gun-end-mode #f) + ) + ) + ) + (set-setting! 'mode-name 'cam-fixed 0 0) + (set-setting! 'interp-time 'abs 0 0) + (apply-settings *setting-control*) + (set! (-> self control transv quad) (the-as uint128 0)) + (logior! (-> self focus-status) (focus-status dead)) + (case arg0 + (('melt 'grenade 'explode) + (let ((s5-0 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) s5-0) (seconds 0.2)) + (suspend) + ) + ) + (case arg0 + (('dark-eco-pool) + (sound-play "death-darkeco") + (let ((s5-2 (get-process *default-dead-pool* part-tracker #x4000))) + (when s5-2 + (let ((t9-14 (method-of-type part-tracker activate))) + (t9-14 + (the-as part-tracker s5-2) + *entity-pool* + (symbol->string (-> part-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-15 run-function-in-process) + (a0-36 s5-2) + (a1-19 part-tracker-init) + (a2-11 (-> *part-group-id-table* 56)) + (a3-7 0) + (t0-6 #f) + (t1-6 #f) + (t2-1 #f) + (t3-0 *launch-matrix*) + ) + (set! (-> t3-0 trans quad) (-> self control trans quad)) + ((the-as (function object object object object object object object object none) t9-15) + a0-36 + a1-19 + a2-11 + a3-7 + t0-6 + t1-6 + t2-1 + t3-0 + ) + ) + (-> s5-2 ppointer) + ) + ) + ) + (('grenade 'explode) + (sound-play "explosion") + (let ((s5-4 (get-process *default-dead-pool* part-tracker #x4000))) + (when s5-4 + (let ((t9-19 (method-of-type part-tracker activate))) + (t9-19 + (the-as part-tracker s5-4) + *entity-pool* + (symbol->string (-> part-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-20 run-function-in-process) + (a0-45 s5-4) + (a1-24 part-tracker-init) + (a2-17 (-> *part-group-id-table* 58)) + (a3-10 0) + (t0-8 #f) + (t1-8 #f) + (t2-3 #f) + (t3-1 *launch-matrix*) + ) + (set! (-> t3-1 trans quad) (-> self control trans quad)) + ((the-as (function object object object object object object object object none) t9-20) + a0-45 + a1-24 + a2-17 + a3-10 + t0-8 + t1-8 + t2-3 + t3-1 + ) + ) + (-> s5-4 ppointer) + ) + ) + ) + (('lava 'melt) + (sound-play "death-melt") + (let ((s5-6 (get-process *default-dead-pool* part-tracker #x4000))) + (when s5-6 + (let ((t9-24 (method-of-type part-tracker activate))) + (t9-24 + (the-as part-tracker s5-6) + *entity-pool* + (symbol->string (-> part-tracker symbol)) + (the-as pointer #x70004000) + ) + ) + (let ((t9-25 run-function-in-process) + (a0-52 s5-6) + (a1-29 part-tracker-init) + (a2-23 (-> *part-group-id-table* 57)) + (a3-13 0) + (t0-10 #f) + (t1-10 #f) + (t2-5 #f) + (t3-2 *launch-matrix*) + ) + (set! (-> t3-2 trans quad) (-> self control trans quad)) + ((the-as (function object object object object object object object object none) t9-25) + a0-52 + a1-29 + a2-23 + a3-13 + t0-10 + t1-10 + t2-5 + t3-2 + ) + ) + (-> s5-6 ppointer) + ) + ) + ) + ) + (let ((v1-73 (-> self control root-prim))) + (set! (-> v1-73 prim-core collide-as) (collide-spec)) + (set! (-> v1-73 prim-core collide-with) (collide-spec)) + ) + 0 + (ja-channel-set! 0) + (let ((s5-7 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) s5-7) (seconds 1.8)) + (suspend) + ) + ) + ) + (('endlessfall) + (sound-play "death-fall") + (if (not (-> self pilot as-daxter?)) + (set! (-> self control unknown-sound-id00) + (add-process *gui-control* *target* (gui-channel daxter) (gui-action play) "jakfall" -99.0 0) + ) + ) + (set-falloff! *gui-control* (-> self control unknown-sound-id00) #t -1 100 2) + (logclear! (-> self water flags) (water-flags swim-ground)) + (let ((f0-2 (fmin -4096.0 (- (-> self control ground-impact-vel))))) + (set! (-> self control unknown-word04) (the-as uint f0-2)) + (let ((v1-94 (new-stack-vector0))) + (let ((f1-3 (vector-dot (-> self control dynam gravity-normal) (-> self control transv)))) + 0.0 + (vector-! v1-94 (-> self control transv) (vector-float*! v1-94 (-> self control dynam gravity-normal) f1-3)) + ) + (let* ((f1-4 (vector-length v1-94)) + (f2-1 f1-4) + ) + (vector+! + (-> self control transv) + (vector-float*! (-> self control transv) (-> self control dynam gravity-normal) f0-2) + (vector-float*! v1-94 v1-94 (/ f1-4 f2-1)) + ) + ) + ) + ) + (let ((s5-9 (-> self clock frame-counter))) + (until (>= (- (-> self clock frame-counter) s5-9) (seconds 0.5)) + (suspend) + ) + ) + ) + (('bot) + (set! (-> self trans-hook) #f) + (while (not (-> self control unknown-spool-anim00)) + (set-forward-vel 0.0) + (suspend) + ) + ) + (else + ) + ) + (target-death-reset arg0 #f) + (none) + ) + :post target-pilot-post + ) diff --git a/test/decompiler/reference/jak2/levels/city/common/target-pilot_REF.gc b/test/decompiler/reference/jak2/levels/city/common/target-pilot_REF.gc new file mode 100644 index 0000000000..66df9c6ede --- /dev/null +++ b/test/decompiler/reference/jak2/levels/city/common/target-pilot_REF.gc @@ -0,0 +1,487 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *pilot-mods*, type surface +(define *pilot-mods* (new 'static 'surface :name 'empty :seek0 1.0 :seek90 1.0 :seek180 1.0 :fric 1.0)) + +;; definition for function target-pilot-handler +;; WARN: Return type mismatch none vs object. +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 59] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 64] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 82] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 130] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 150] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 182] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 96] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 114] +;; WARN: disable def twice: 124. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare. +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 47] +;; WARN: rewrite_to_get_var got a none typed variable. Is there unreachable code? [OP: 9] +(defbehavior target-pilot-handler target ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (the-as + object + (cond + ((and (= arg2 'query) (= (-> arg3 param 0) 'mode)) + 'pilot + ) + (else + (case arg2 + (('end-mode) + (let ((v1-4 (-> self pilot))) + (when (nonzero? v1-4) + (let ((a0-5 (handle->process (-> v1-4 vehicle)))) + (if a0-5 + (put-rider-in-seat (the-as vehicle a0-5) (-> v1-4 seat-index) (the-as process-focusable #f)) + ) + ) + ) + ) + enter-state + (process->handle arg0) + (go target-pilot-get-off) + ) + (('change-mode) + (case (-> arg3 param 0) + (('grab) + (when (not (logtest? (-> self focus-status) (focus-status dead))) + (if (not (-> arg3 param 1)) + #t + (go target-pilot-grab) + ) + ) + ) + (('normal) + enter-state + (process->handle arg0) + (go target-pilot-get-off) + ) + (('gun) + (if (logtest? (-> self game features) (game-feature gun)) + (target-gun-init (the-as int (-> arg3 param 2))) + ) + ) + ) + ) + (('swim) + #f + ) + (('clone-anim) + (go target-pilot-clone-anim (process->handle (the-as process (-> arg3 param 0)))) + ) + (('get-vehicle) + (if (nonzero? (-> self pilot)) + (handle->process (-> self pilot vehicle)) + ) + ) + (('attack 'attack-or-shove 'attack-invinc) + (target-attacked + arg2 + (the-as attack-info (-> arg3 param 1)) + arg0 + (the-as touching-shapes-entry (-> arg3 param 0)) + target-pilot-hit + ) + ) + (('vehicle-hit) + (speech-control-method-12 *speech-control* self (if (-> self pilot as-daxter?) + (speech-type speech-type-1 speech-type-3 speech-type-5) + (speech-type speech-type-0 speech-type-5) + ) + ) + ) + (('vehicle-got-hit) + (speech-control-method-12 + *speech-control* + self + (if (-> self pilot as-daxter?) + (speech-type speech-type-0 speech-type-1 speech-type-3 speech-type-5) + (speech-type speech-type-1 speech-type-5) + ) + ) + ) + (else + (target-standard-event-handler arg0 arg1 arg2 arg3) + ) + ) + ) + ) + ) + ) + +;; definition for function target-pilot-pidax-enter +(defbehavior target-pilot-pidax-enter target () + (set! (-> self pilot art-group-backup) (-> self draw art-group)) + (set! (-> self draw art-group) (-> self sidekick 0 draw art-group)) + (logior! (-> self draw status) (draw-control-status no-draw-bounds2)) + (send-event (ppointer->process (-> self sidekick)) 'matrix 'indax) + ) + +;; definition for function target-pilot-pidax-exit +(defbehavior target-pilot-pidax-exit target () + (ja-channel-set! 0) + (set! (-> self draw art-group) (the-as art-group (-> self pilot art-group-backup))) + (logclear! (-> self draw status) (draw-control-status no-draw-bounds2)) + (send-event (ppointer->process (-> self sidekick)) 'matrix #f) + ) + +;; definition for function target-pilot-exit +;; INFO: Used lq/sq +;; WARN: Return type mismatch none vs object. +(defbehavior target-pilot-exit target () + (the-as + object + (when (not (and (-> self next-state) (let ((v1-3 (-> self next-state name))) + (or (= v1-3 'target-pilot-stance) + (= v1-3 'target-pilot-impact) + (= v1-3 'target-pilot-get-off) + (= v1-3 'target-pilot-grab) + (= v1-3 'target-pilot-clone-anim) + (= v1-3 'target-pilot-hit) + (= v1-3 'target-pilot-death) + ) + ) + ) + ) + (let ((v1-4 (-> self manipy))) + (when v1-4 + (deactivate (-> v1-4 0)) + (set! (-> self manipy) (the-as (pointer manipy) #f)) + ) + ) + (if (-> self pilot as-daxter?) + (target-pilot-pidax-exit) + ) + (let ((v1-11 (-> self pilot))) + (when (nonzero? v1-11) + (set! (-> self control nav-radius) (-> v1-11 backup-nav-radius)) + (let ((gp-0 (handle->process (-> v1-11 vehicle)))) + (when gp-0 + (remove-rider (the-as vehicle gp-0) self) + (send-event gp-0 'player-get-off) + ) + ) + ) + ) + (set! (-> self neck flex-blend) 1.0) + (let ((v1-22 (-> self control root-prim))) + (set! (-> v1-22 prim-core collide-as) (-> self control backup-collide-as)) + (set! (-> v1-22 prim-core collide-with) (-> self control backup-collide-with)) + ) + (logclear! (-> self focus-status) (focus-status pilot-riding pilot)) + (logclear! (-> self control root-prim prim-core action) (collide-action stuck-wall-escape)) + (set! (-> self control mod-surface) *walk-mods*) + (logclear! (-> self state-flags) (state-flags sf6)) + (enable-set! (-> self arm-ik 0) #f) + (enable-set! (-> self arm-ik 1) #f) + (set! (-> self control dynam gravity-max) (-> self control standard-dynamics gravity-max)) + (set! (-> self control dynam gravity-length) (-> self control standard-dynamics gravity-length)) + (let ((v1-43 (-> self node-list data))) + (set! (-> v1-43 0 param0) (the-as (function cspace transformq none) cspace<-transformq+trans!)) + (set! (-> v1-43 0 param1) (the-as basic (-> self control trans))) + (set! (-> v1-43 0 param2) (the-as basic (-> self control cspace-offset))) + ) + (target-collide-set! 'normal 0.0) + (set! (-> self control reaction) target-collision-reaction) + (set! (-> self control cspace-offset quad) (the-as uint128 0)) + (target-exit) + ) + ) + ) + +;; definition for function target-pilot-init +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs object. +(defbehavior target-pilot-init target ((arg0 handle) (arg1 symbol)) + (target-exit) + (if (zero? (-> self pilot)) + (set! (-> self pilot) (new 'process 'pilot-info)) + ) + (let ((s5-0 (-> self pilot))) + (set! (-> s5-0 backup-nav-radius) (-> self control nav-radius)) + (set! (-> s5-0 gun?) #t) + (set! (-> s5-0 enable-cam-side-shift) #f) + (set! (-> s5-0 as-daxter?) arg1) + (set! (-> s5-0 entity) #f) + (set! (-> s5-0 cam-side-shift) 0.0) + (if (-> self pilot as-daxter?) + (target-pilot-pidax-enter) + ) + (cond + ((handle->process arg0) + (set! (-> s5-0 vehicle) arg0) + ) + (else + (break!) + 0 + ) + ) + (let ((s4-1 (handle->process (-> s5-0 vehicle)))) + (when s4-1 + (set! (-> s5-0 entity) (-> s4-1 entity)) + (set! (-> s5-0 gun?) (logtest? (-> (the-as vehicle s4-1) info-override flags) 32)) + (set! (-> s5-0 enable-cam-side-shift) (logtest? (-> (the-as vehicle s4-1) info-override flags) 128)) + (send-event + (ppointer->process (-> (the-as vehicle s4-1) parent)) + 'player-got-on-vehicle-child + (the-as vehicle s4-1) + ) + (set! (-> s5-0 stance) (vehicle-method-72 (the-as vehicle s4-1))) + (let ((s3-0 (get-seat-count (the-as vehicle s4-1)))) + (dotimes (s2-0 s3-0) + (let ((a0-20 (get-rider-in-seat (the-as vehicle s4-1) s2-0))) + (if (and a0-20 (send-event a0-20 'knocked-off)) + (put-rider-in-seat (the-as vehicle s4-1) s2-0 (the-as process-focusable #f)) + ) + ) + ) + ) + (let ((v1-43 (get-best-seat-for-vehicle s4-1 (-> self control trans) 1 1))) + (set! (-> s5-0 seat-index) (max 0 v1-43)) + ) + (cond + ((-> s5-0 as-daxter?) + (set! (-> s5-0 left-right-accel-factor) 0.0000012207031) + (set! (-> s5-0 front-back-accel-factor) 0.0000012207031) + (set! (-> s5-0 up-down-accel-factor) 0.0000012207031) + ) + ((zero? (-> s5-0 stance)) + (set! (-> s5-0 left-right-accel-factor) 0.0000012207031) + (set! (-> s5-0 front-back-accel-factor) 0.0000012207031) + (set! (-> s5-0 up-down-accel-factor) 0.00000051879886) + ) + (else + (set! (-> s5-0 left-right-accel-factor) 0.0000012207031) + (set! (-> s5-0 front-back-accel-factor) 0.0000012207031) + (set! (-> s5-0 up-down-accel-factor) 0.00000061035155) + ) + ) + ) + ) + (when (not (-> s5-0 gun?)) + (if arg1 + (set! (-> self control current-surface flags) + (logior (surface-flag gun-fast-exit) (-> self control current-surface flags)) + ) + ) + (target-gun-end-mode arg1) + ) + ) + (set! (-> self board latch?) #f) + (set! (-> self control reaction) target-collision-reaction) + (set! (-> self control transv quad) (the-as uint128 0)) + (set! (-> self control ctrl-xz-vel) 0.0) + (set! (-> self focus-status) (logior (focus-status pilot) (-> self focus-status))) + (set! (-> self control bend-target) 0.0) + (let ((v1-73 (-> self node-list data))) + (set! (-> v1-73 0 param0) (the-as (function cspace transformq none) cspace<-transformq+world-trans!)) + (set! (-> v1-73 0 param1) (the-as basic (-> self control trans))) + (set! (-> v1-73 0 param2) (the-as basic (-> self control cspace-offset))) + ) + (let ((v1-75 (-> self control root-prim))) + (set! (-> v1-75 prim-core collide-as) (collide-spec)) + (set! (-> v1-75 prim-core collide-with) (collide-spec)) + ) + 0 + (set! (-> self control root-prim prim-core collide-as) (collide-spec jak-vehicle)) + (set! (-> self neck flex-blend) 0.0) + (set! (-> self control status) (collide-status)) + (the-as object 0) + ) + +;; definition for function pilot-on-ground? +(defbehavior pilot-on-ground? target () + (logtest? (-> self control status) (collide-status on-surface)) + ) + +;; definition for function target-pilot-post +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defbehavior target-pilot-post target () + (local-vars (v1-55 symbol) (a0-44 object) (a0-56 int) (a0-58 int)) + (let* ((v1-1 (-> *perf-stats* data 17)) + (a0-0 (-> v1-1 ctrl)) + ) + (+! (-> v1-1 count) 1) + (b! (zero? a0-0) cfg-2 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mtpc pcr0 0) + (.mtpc pcr1 0) + (.sync.l) + (.sync.p) + (.mtc0 Perf a0-0) + ) + (.sync.l) + (.sync.p) + (label cfg-2) + 0 + (let ((f30-0 (-> self clock clock-ratio))) + (let ((gp-1 (max 1 (the int (-> self clock time-adjust-ratio))))) + (update-rates! (-> self clock) (/ f30-0 (the float gp-1))) + (b! #t cfg-4 :delay (nop!)) + (label cfg-3) + (+! gp-1 -1) + (set! (-> self control remaining-ctrl-iterations) gp-1) + (flag-setup) + (build-conversions (-> self control transv)) + (do-rotations1) + (do-rotations2) + (reverse-conversions (-> self control transv)) + (vector-! + (-> self control cspace-offset) + (-> self control draw-offset) + (-> self control anim-collide-offset-world) + ) + (let ((a1-5 (new 'stack-no-clear 'overlaps-others-params))) + (set! (-> a1-5 options) (overlaps-others-options oo0)) + (set! (-> a1-5 collide-with-filter) (the-as collide-spec -1)) + (set! (-> a1-5 tlist) *touching-list*) + (find-overlapping-shapes (-> self control) a1-5) + ) + (post-flag-setup) + (label cfg-4) + (b! (nonzero? gp-1) cfg-3 :delay (nop!)) + ) + (update-rates! (-> self clock) f30-0) + ) + (let* ((gp-2 (-> self pilot)) + (s5-0 (handle->process (-> gp-2 vehicle))) + ) + (when s5-0 + (compute-seat-position (the-as vehicle s5-0) (-> self control trans) (-> gp-2 seat-index)) + (set! (-> self control transv quad) (-> (the-as vehicle s5-0) root-override-2 transv quad)) + (quaternion-copy! (-> self control quat) (-> (the-as vehicle s5-0) root-override-2 quat)) + (quaternion-copy! (-> self control quat-for-control) (-> self control quat)) + (quaternion-copy! (-> self control dir-targ) (-> self control quat)) + (let ((s4-0 (-> self alt-cam-pos))) + (when (not (logtest? (-> self focus-status) (focus-status dead))) + (let ((s3-0 (new 'stack-no-clear 'collide-query-with-5vec))) + (set! (-> s3-0 vec 2 x) 0.0) + (set! (-> s3-0 vec 2 y) 20480.0) + (let ((a0-18 (-> self node-list data 0 bone transform))) + (set! (-> s3-0 vec 1 quad) (-> a0-18 vector 2 quad)) + ) + (set! (-> s3-0 vec 1 y) 0.0) + (vector-rotate90-around-y! (-> s3-0 vec 1) (-> s3-0 vec 1)) + (vector-normalize! (-> s3-0 vec 1) 1.0) + (set! (-> s3-0 vec 0 quad) (-> self control trans quad)) + (when (-> gp-2 enable-cam-side-shift) + (let ((s2-0 0)) + (b! #t cfg-22 :delay (nop!)) + (label cfg-14) + (let ((v1-48 (-> s3-0 cquery))) + (set! (-> v1-48 radius) 2048.0) + (set! (-> v1-48 collide-with) (collide-spec backgnd)) + (set! (-> v1-48 ignore-process0) #f) + (set! (-> v1-48 ignore-process1) #f) + (set! (-> v1-48 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> v1-48 action-mask) (collide-action solid)) + ) + (set! (-> s3-0 cquery start-pos quad) (-> s3-0 vec 0 quad)) + (vector-float*! (-> s3-0 cquery move-dist) (-> s3-0 vec 1) (-> s3-0 vec 2 y)) + (let ((f0-10 (fill-and-probe-using-line-sphere *collide-cache* (-> s3-0 cquery)))) + (let ((v1-54 (>= f0-10 0.0))) + (b! (not v1-54) cfg-19 :likely-delay (set! v1-55 v1-54)) + ) + (set! v1-55 (= (-> s3-0 cquery best-other-tri pat mode) (pat-mode wall))) + (label cfg-19) + (when v1-55 + (+! (-> s3-0 vec 2 x) (* -1.0 (-> s3-0 vec 2 y) (- 1.0 f0-10))) + 0 + ) + ) + (set! (-> s3-0 vec 2 y) (* -1.0 (-> s3-0 vec 2 y))) + (+! s2-0 1) + (label cfg-22) + (b! (< s2-0 2) cfg-14) + ) + (set! (-> s3-0 vec 2 x) + (* (-> s3-0 vec 2 x) (fmax 0.25 (fmin 1.0 (* 0.000008138021 (vector-length (-> self control transv)))))) + ) + (seek! (-> gp-2 cam-side-shift) (-> s3-0 vec 2 x) (* 16384.0 (-> self clock seconds-per-frame))) + ) + (set! (-> s4-0 x) (+ (-> s3-0 vec 0 x) (* (-> gp-2 cam-side-shift) (-> s3-0 vec 1 x)))) + (set! (-> s4-0 z) (+ (-> s3-0 vec 0 z) (* (-> gp-2 cam-side-shift) (-> s3-0 vec 1 z)))) + (set! (-> s4-0 y) (fmax (fmin (-> s4-0 y) (+ 2048.0 (-> s3-0 vec 0 y))) (+ -2048.0 (-> s3-0 vec 0 y)))) + ) + 0 + ) + ) + (let ((s4-1 (new 'stack-no-clear 'matrix))) + (vehicle-method-117 (the-as vehicle s5-0) (the-as vector (-> s4-1 vector)) (-> gp-2 seat-index) 0) + (vehicle-method-117 (the-as vehicle s5-0) (-> s4-1 vector 1) (-> gp-2 seat-index) 1) + (enable-set! (-> self arm-ik 0) #t) + (enable-set! (-> self arm-ik 1) #t) + (handle-copy! (-> self arm-ik 0) (the-as vector (-> s4-1 vector))) + (handle-copy! (-> self arm-ik 1) (-> s4-1 vector 1)) + ) + ) + ) + (when *debug-segment* + (let ((gp-3 (-> *display* frames (-> *display* on-screen) profile-array data 0)) + (v1-97 'target-post) + (s5-1 *profile-target-post-color*) + ) + (let ((a0-43 *dproc*)) + (b! (not a0-43) cfg-30 :likely-delay (set! a0-44 a0-43)) + ) + (set! a0-44 *debug-segment*) + (label cfg-30) + (when a0-44 + (let ((s4-2 (-> gp-3 data (-> gp-3 count)))) + (let ((s3-1 (-> gp-3 base-time))) + (set! (-> s4-2 name) v1-97) + (set! (-> s4-2 start-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s3-1)))) + ) + (set! (-> s4-2 depth) (the-as uint (-> gp-3 depth))) + (set! (-> s4-2 color) s5-1) + (set! (-> gp-3 segment (-> gp-3 depth)) s4-2) + ) + (+! (-> gp-3 count) 1) + (+! (-> gp-3 depth) 1) + (set! (-> gp-3 max-depth) (max (-> gp-3 max-depth) (-> gp-3 depth))) + ) + ) + 0 + ) + (ja-post) + (when *debug-segment* + (let ((gp-4 (-> *display* frames (-> *display* on-screen) profile-array data 0))) + (when (and *dproc* *debug-segment*) + (let* ((v1-121 (+ (-> gp-4 depth) -1)) + (s5-2 (-> gp-4 segment v1-121)) + (s4-3 (-> gp-4 base-time)) + ) + (when (>= v1-121 0) + (set! (-> s5-2 end-time) (the-as int (- (timer-count (the-as timer-bank #x10000800)) (the-as uint s4-3)))) + (+! (-> gp-4 depth) -1) + ) + ) + ) + ) + 0 + ) + (joint-points) + (update-transforms (-> self control)) + (do-target-gspot) + (target-powerup-process) + (let ((v1-130 (-> *perf-stats* data 17))) + (b! (zero? (-> v1-130 ctrl)) cfg-43 :delay (nop!)) + (.mtc0 Perf 0) + (.sync.l) + (.sync.p) + (.mfpc a0-56 pcr0) + (+! (-> v1-130 accum0) a0-56) + (.mfpc a0-58 pcr1) + (+! (-> v1-130 accum1) a0-58) + ) + (label cfg-43) + 0 + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak2/levels/city/common/test-bike_REF.gc b/test/decompiler/reference/jak2/levels/city/common/test-bike_REF.gc new file mode 100644 index 0000000000..7654f6b617 --- /dev/null +++ b/test/decompiler/reference/jak2/levels/city/common/test-bike_REF.gc @@ -0,0 +1,508 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type test-bike +(deftype test-bike (bikec) + () + :heap-base #x320 + :method-count-assert 144 + :size-assert #x39c + :flag-assert #x900320039c + ) + +;; definition for method 3 of type test-bike +(defmethod inspect test-bike ((obj test-bike)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type bikec inspect))) + (t9-0 obj) + ) + (label cfg-4) + obj + ) + +;; definition for symbol *test-bike-constants*, type rigid-body-vehicle-constants +(define *test-bike-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 2.0 + :inv-mass 0.5 + :linear-damping 0.995 + :angular-damping 0.995 + :friction-factor 0.516 + :cm-offset-joint (new 'static 'vector :z 2457.6 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 1.5) (meters 2) (meters 5)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*test-bike-constants* + :flags #x11 + :object-type #xd + :guard-type #x7 + :max-engine-thrust (meters 50) + :inv-max-engine-thrust 0.0000048828124 + :engine-response-rate 32.0 + :engine-intake-factor 1.0 + :brake-factor 2.0 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 100) + :ground-probe-distance (meters 5) + :ground-probe-offset (meters 0.5) + :cos-ground-effect-angle -0.00000004371139 + :spring-lift-factor 0.35 + :air-drag-factor 1.2 + :steering-fin-angle 1820.4445 + :steering-thruster-factor 6.0 + :steering-thruster-max-gain 2.0 + :steering-thruster-half-gain-speed (meters 80) + :tire-steering-angle 1274.3112 + :tire-static-friction 0.5 + :tire-static-friction-speed (meters 1) + :tire-dynamic-friction 0.25 + :tire-dynamic-friction-speed (meters 3) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 8.0 + :drag-force-factor 1.0 + :speed-limiting-drag 0.75 + :pitch-control-factor 0.5 + :roll-control-factor 1.0 + :roll-angle 7281.778 + :jump-thrust-factor 0.625 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 0.125) + :target-speed-offset (meters 4) + :turning-accel (meters 20) + :toughness-factor 1.0 + :damage-factor 4.0 + :camera-string-min-height (meters 2.5) + :camera-string-max-height (meters 2.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 5.5) + :camera-min-fov 16384.0 + :camera-max-fov 18204.445 + :camera-head-offset 4096.0 + :camera-foot-offset -4096.0 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 2 + :section-count 2 + :grab-rail-count 2 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 2 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x 2048.0 :z 8192.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -2048.0 :z 8192.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 802.816 :z 1318.912 :w (the-as float #x10000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 2048.0 :z -4096.0 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 409.6 :z 4710.4 :w 1.0) + (new 'static 'vector :x -2457.6 :y 409.6 :z 4710.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x20 #x8 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x40 #x10 #x4) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-offset -0.25 + :engine-pitch-mod-amp 0.05 + :engine-sound-select 2 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "bike-scrape-stn") + :glance-sound (static-sound-name "bike-glance-stn") + :impact-sound (static-sound-name "bike-impact-stn") + :extra-sound (static-sound-name "car-by-1") + :explosion-part #xa1 + :headlight-count 1 + :taillight-count 1 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :z -3276.8 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :y 204.8 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :y 204.8 :z -3276.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1638.4 :y -2048.0 :z 7372.8 :w 1.0) + (new 'static 'vector :x -1638.4 :y -2048.0 :z 7372.8 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 (new 'static 'vector :w 1.0) (new 'static 'vector :w 1.0)) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :y -614.4 :z 13721.6 :w 1.0) + (new 'static 'vector) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 (new 'static 'vector :y 614.4 :z -7168.0 :w 1.0) (new 'static 'vector)) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 7372.8003 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -2457.6 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10240.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5324.8 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10649.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.25) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.75) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 0.25) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :brake-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :color-option-count 1 + :color-option-array (new 'static 'inline-array vector 1 (new 'static 'vector :x 1.0 :y 1.0 :z 1.0 :w 1.0)) + ) + ) + +;; definition for method 33 of type test-bike +;; WARN: Return type mismatch int vs none. +(defmethod init-skel-and-rigid-body test-bike ((obj test-bike)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-bikec" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *test-bike-constants*) + (set! (-> obj fin-fl) (new 'process 'joint-mod-rotate-local obj 7 #t)) + (set! (-> obj fin-fr) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 9 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 10 #t)) + (set! (-> obj fin2-fl) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj fin2-fr) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj rudder) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj brake-l) (new 'process 'joint-mod-rotate-local obj 11 #t)) + (set! (-> obj brake-r) (new 'process 'joint-mod-rotate-local obj 12 #t)) + (set! (-> obj spoiler-l) (new 'process 'joint-mod-rotate-local obj 13 #t)) + (set! (-> obj spoiler-r) (new 'process 'joint-mod-rotate-local obj 14 #t)) + 0 + (none) + ) + +;; definition of type evan-test-bike +(deftype evan-test-bike (bikea) + () + :heap-base #x310 + :method-count-assert 144 + :size-assert #x38c + :flag-assert #x900310038c + ) + +;; definition for method 3 of type evan-test-bike +(defmethod inspect evan-test-bike ((obj evan-test-bike)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type bikea inspect))) + (t9-0 obj) + ) + (label cfg-4) + obj + ) + +;; definition for symbol *evan-test-bike-constants*, type rigid-body-vehicle-constants +(define *evan-test-bike-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 2.0 + :inv-mass 0.5 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :z 2457.6 :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 3) (meters 4) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*evan-test-bike-constants* + :flags #x70 + :object-type #xb + :guard-type #x7 + :max-engine-thrust (meters 50) + :inv-max-engine-thrust 0.0000048828124 + :engine-response-rate 30.0 + :engine-intake-factor 1.0 + :brake-factor 2.0 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.3 + :air-drag-factor 1.0 + :steering-thruster-factor 5.0 + :steering-thruster-max-gain 4.0 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.5 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.75 + :pitch-control-factor 1.0 + :roll-control-factor 1.0 + :jump-thrust-factor 0.625 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 4) + :turning-accel (meters 20) + :toughness-factor 1.0 + :damage-factor 4.0 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 5461.3335 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 2 + :section-count 2 + :grab-rail-count 2 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 2 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2048.0 :w 1.0) + (new 'static 'vector :x 2048.0 :z 4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -2048.0 :z 4096.0 :w 1.0) + (new 'static 'vector :x -2048.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info :position (new 'static 'vector :w (the-as float #x10000))) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 2048.0 :z -4096.0 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 2457.6 :y 409.6 :z 4710.4 :w 1.0) + (new 'static 'vector :x -2457.6 :y 409.6 :z 4710.4 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x10 #x8 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x20 #x4 #x0) + :damage-seg-count 2 + ) + :explosion #f + :engine-pitch-scale 0.25 + :engine-pitch-offset -0.25 + :engine-pitch-mod-amp 0.05 + :engine-sound-select 1 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "bike-scrape-stn") + :glance-sound (static-sound-name "bike-glance-stn") + :impact-sound (static-sound-name "bike-impact-stn") + :extra-sound (static-sound-name "bike-by-1") + :explosion-part #xa1 + :headlight-count 1 + :taillight-count 1 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :z -3276.8 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1024.0 :y 204.8 :z -3276.8 :w 1.0) + (new 'static 'vector :x -1024.0 :y 204.8 :z -3276.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 1638.4 :y -2048.0 :z 7372.8 :w 1.0) + (new 'static 'vector :x -1638.4 :y -2048.0 :z 7372.8 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 (new 'static 'vector :w 1.0) (new 'static 'vector :w 1.0)) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :y -819.2 :z 10240.0 :w 1.0) + (new 'static 'vector) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 (new 'static 'vector :y 1433.6 :z -10240.0 :w 1.0) (new 'static 'vector)) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z 7372.8003 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z -2457.6 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10240.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5324.8 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 10649.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 2457.6 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :brake-local-pos (new 'static 'vector :z -3276.7998 :w 1.0) + :color-option-count 1 + :color-option-array (new 'static 'inline-array vector 1 (new 'static 'vector :x 0.6 :y 0.6 :z 1.5 :w 1.0)) + ) + ) + +;; definition for method 33 of type evan-test-bike +;; WARN: Return type mismatch int vs none. +(defmethod init-skel-and-rigid-body evan-test-bike ((obj evan-test-bike)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-bikea" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *evan-test-bike-constants*) + (set! (-> obj fin-fl) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj fin-fr) (new 'process 'joint-mod-rotate-local obj 7 #t)) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj rudder) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj brake-l) (new 'process 'joint-mod-rotate-local obj 9 #t)) + (set! (-> obj brake-r) (new 'process 'joint-mod-rotate-local obj 10 #t)) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak2/levels/city/common/test-car_REF.gc b/test/decompiler/reference/jak2/levels/city/common/test-car_REF.gc new file mode 100644 index 0000000000..9b0fb43680 --- /dev/null +++ b/test/decompiler/reference/jak2/levels/city/common/test-car_REF.gc @@ -0,0 +1,304 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type test-car +(deftype test-car (cara) + () + :heap-base #x320 + :method-count-assert 144 + :size-assert #x398 + :flag-assert #x9003200398 + ) + +;; definition for method 3 of type test-car +(defmethod inspect test-car ((obj test-car)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (let ((t9-0 (method-of-type cara inspect))) + (t9-0 obj) + ) + (label cfg-4) + obj + ) + +;; definition for symbol *test-car-constants*, type rigid-body-vehicle-constants +(define *test-car-constants* + (new 'static 'rigid-body-vehicle-constants + :info (new 'static 'rigid-body-info + :mass 8.0 + :inv-mass 0.125 + :linear-damping 0.995 + :angular-damping 0.995 + :bounce-factor 0.4 + :friction-factor 0.05 + :bounce-mult-factor 1.22 + :cm-offset-joint (new 'static 'vector :w 1.0) + :inertial-tensor-box (new 'static 'array meters 3 (meters 4) (meters 3) (meters 6)) + ) + :extra (new 'static 'rigid-body-object-extra-info + :max-time-step 0.033333335 + :gravity (meters 40) + :idle-distance (meters 50) + :attack-force-scale 1.0 + ) + :name '*test-car-constants* + :flags #x68 + :object-type #xe + :guard-type #x7 + :max-engine-thrust (meters 39) + :inv-max-engine-thrust 0.000006260016 + :engine-response-rate 20.0 + :engine-intake-factor 1.0 + :brake-factor 1.0 + :turbo-boost-factor 1.0 + :max-xz-speed (meters 40) + :ground-probe-distance (meters 4.5) + :cos-ground-effect-angle 0.42261824 + :spring-lift-factor 0.4 + :air-drag-factor 1.0 + :steering-thruster-factor 3.0 + :steering-thruster-max-gain 3.5 + :steering-thruster-half-gain-speed (meters 15) + :tire-friction-factor 0.6 + :tire-static-friction 0.55 + :tire-dynamic-friction 0.4 + :tire-dynamic-friction-speed (meters 2) + :tire-inv-max-friction-speed 0.000024414063 + :airfoil-factor 1.0 + :drag-force-factor 1.0 + :speed-scrubbing-drag 10.0 + :speed-limiting-drag 0.7 + :pitch-control-factor 0.5 + :roll-control-factor 1.0 + :jump-thrust-factor 0.5 + :buoyancy-factor 1.0 + :player-weight 163840.0 + :player-shift-x (meters 0.6) + :player-shift-z (meters 1) + :target-speed-offset (meters 3) + :turning-accel (meters 20) + :toughness-factor 1.0 + :damage-factor 2.5 + :camera-string-min-height (meters 4.5) + :camera-string-max-height (meters 4.5) + :camera-string-min-length (meters 5) + :camera-string-max-length (meters 12.5) + :camera-min-fov 15109.688 + :camera-max-fov 17476.268 + :camera-head-offset 8192.0 + :camera-foot-offset 4096.0 + :camera-normal-max-angle-offset 5461.3335 + :camera-air-max-angle-offset 5461.3335 + :camera-max-lookaround-speed 40960.0 + :seat-count 3 + :section-count 4 + :rider-stance #x1 + :grab-rail-count #x6 + :grab-rail-array (new 'static 'inline-array vehicle-grab-rail-info 6 + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 4505.6 :y -2662.4 :z 15360.0 :w 1.0) + (new 'static 'vector :x -4505.6 :y -2662.4 :z 15360.0 :w 1.0) + ) + :normal (new 'static 'vector :z 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 7372.8 :y -819.2 :z -4096.0 :w 1.0) + (new 'static 'vector :x 7372.8 :y -819.2 :z 4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -7372.8 :y -819.2 :z 4096.0 :w 1.0) + (new 'static 'vector :x -7372.8 :y -819.2 :z -4096.0 :w 1.0) + ) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -3686.4 :y -409.6 :z -14950.4 :w 1.0) + (new 'static 'vector :x 3686.4 :y -409.6 :z -14950.4 :w 1.0) + ) + :normal (new 'static 'vector :z -1.0 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3837.952 :y -409.6 :z -14950.4 :w 1.0) + (new 'static 'vector :x 6041.6 :y -614.4 :z -9011.2 :w 1.0) + ) + :normal (new 'static 'vector :x 0.707 :z -0.707 :w 1.0) + ) + (new 'static 'vehicle-grab-rail-info + :local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x -6041.6 :y -614.4 :z -9011.2 :w 1.0) + (new 'static 'vector :x -3837.952 :y -409.6 :z -14950.4 :w 1.0) + ) + :normal (new 'static 'vector :x -0.707 :z -0.707 :w 1.0) + ) + ) + :seat-array (new 'static 'inline-array vehicle-seat-info 4 + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :x 4079.616 :y 819.2 :z -311.296 :w (the-as float #x30000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :x -4079.616 :y 819.2 :z -311.296 :w (the-as float #x30000)) + ) + (new 'static 'vehicle-seat-info + :position (new 'static 'vector :y 3751.936 :z -10563.584 :w (the-as float #x40000)) + ) + (new 'static 'vehicle-seat-info) + ) + :rider-hand-offset (new 'static 'inline-array vector 2 + (new 'static 'vector :x 614.4 :y 614.4 :z 1433.6 :w 1.0) + (new 'static 'vector :x 614.4 :y 614.4 :z -1433.6 :w 1.0) + ) + :section-bike-front (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x200 #x20 #x2) + :damage-seg-count 3 + ) + :section-bike-rear (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x400 #x40 #x4) + :damage-seg-count 3 + ) + :section-car-front-right (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x800 #x80 #x8) + :damage-seg-count 3 + ) + :section-car-rear-right (new 'static 'vehicle-section-info + :damage-seg-array (new 'static 'array uint64 3 #x1000 #x100 #x10) + :damage-seg-count 3 + ) + :explosion #f + :engine-pitch-scale 0.09 + :engine-pitch-mod-amp 0.01 + :engine-sound-select 5 + :engine-sound (static-sound-name "vehicle-engine") + :thrust-sound (static-sound-name "bike-thrust") + :scrape-sound (static-sound-name "car-scrape-stn") + :glance-sound (static-sound-name "car-glance-stn") + :impact-sound (static-sound-name "car-impact-stn") + :extra-sound (static-sound-name "car-by-5") + :explosion-part #xa1 + :headlight-count 2 + :taillight-count 2 + :thruster-flame-width (meters 0.6) + :thruster-flame-length (meters 2) + :thruster-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3072.0 :z -14336.0 :w 1.0) + (new 'static 'vector :x -3072.0 :z -14336.0 :w 1.0) + ) + :exhaust-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 6963.2 :y -1024.0 :z -7372.8 :w 1.0) + (new 'static 'vector :x -6963.2 :y -1024.0 :z -7372.8 :w 1.0) + ) + :exhaust-local-dir (new 'static 'inline-array vector 2 (new 'static 'vector :z -1.0 :w 1.0) (new 'static 'vector :z -1.0 :w 1.0)) + :smoke-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3072.0 :z -13926.4 :w 1.0) + (new 'static 'vector :x -3072.0 :z -13926.4 :w 1.0) + ) + :smoke-local-vel (new 'static 'inline-array vector 2 + (new 'static 'vector :x 12288.0 :w 1.0) + (new 'static 'vector :x -12288.0 :w 1.0) + ) + :headlight-local-pos (new 'static 'inline-array vector 3 + (new 'static 'vector :x 4915.2 :z 15564.8 :w 1.0) + (new 'static 'vector :x -4915.2 :z 15564.8 :w 1.0) + (new 'static 'vector) + ) + :taillight-local-pos (new 'static 'inline-array vector 2 + (new 'static 'vector :x 3276.8 :y 3276.8 :z -14131.2 :w 1.0) + (new 'static 'vector :x -3276.8 :y 3276.8 :z -14131.2 :w 1.0) + ) + :lift-thruster-count 2 + :roll-thruster-count 2 + :steering-thruster-count 2 + :stabilizer-count 4 + :inv-lift-thruster-count 0.5 + :lift-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z 8192.0 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :y 819.2 :z -8192.0 :w 1.0) + :normal (new 'static 'vector :y -1.0 :w 1.0) + ) + ) + :roll-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x 6963.2 :y 819.2 :w 1.0) + :normal (new 'static 'vector :x 0.3 :y -0.6 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :x -6963.2 :y 819.2 :w 1.0) + :normal (new 'static 'vector :x -0.3 :y -0.6 :w 1.0) + ) + ) + :steering-thruster-array (new 'static 'inline-array vehicle-control-point 2 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 7782.4 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -7782.4 :w 1.0) + :normal (new 'static 'vector :x -1.0 :w 1.0) + ) + ) + :stabilizer-array (new 'static 'inline-array vehicle-control-point 6 + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -8192.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z 8192.0 :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 0.5) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :w 1.0) + :normal (new 'static 'vector :x 1.0 :w 2.0) + ) + (new 'static 'vehicle-control-point + :local-pos (new 'static 'vector :z -8192.0 :w 1.0) + :normal (new 'static 'vector :y 1.0 :w 1.0) + ) + (new 'static 'vehicle-control-point) + (new 'static 'vehicle-control-point) + ) + :engine-thrust-local-pos (new 'static 'vector :z -5734.4 :w 1.0) + :brake-local-pos (new 'static 'vector :z -8192.0 :w 1.0) + :color-option-count 1 + :color-option-array (new 'static 'inline-array vector 1 (new 'static 'vector :x 0.5 :y 1.0 :z 0.5 :w 1.0)) + ) + ) + +;; definition for method 33 of type test-car +;; WARN: Return type mismatch int vs none. +(defmethod init-skel-and-rigid-body test-car ((obj test-car)) + (initialize-skeleton + obj + (the-as skeleton-group (art-group-get-by-name *level* "skel-cara" (the-as (pointer uint32) #f))) + (the-as pair 0) + ) + (alloc-and-init-rigid-body-control obj *test-car-constants*) + (set! (-> obj rider-hand-joint-array 0) 11) + (set! (-> obj rider-hand-joint-array 1) 12) + (set! (-> obj steering-wheel-l) (new 'process 'joint-mod-rotate-local obj 11 #t)) + (set! (-> obj steering-wheel-r) (new 'process 'joint-mod-rotate-local obj 12 #t)) + (set! (-> obj fin-fl) (new 'process 'joint-mod-rotate-local obj 4 #t)) + (set! (-> obj fin-fr) (new 'process 'joint-mod-rotate-local obj 5 #t)) + (set! (-> obj fin-rl) (new 'process 'joint-mod-rotate-local obj 6 #t)) + (set! (-> obj fin-rr) (new 'process 'joint-mod-rotate-local obj 8 #t)) + (set! (-> obj rudder) (new 'process 'joint-mod-rotate-local obj 10 #t)) + (set! (-> obj rudder-l) (new 'process 'joint-mod-rotate-local obj 7 #t)) + (set! (-> obj rudder-r) (new 'process 'joint-mod-rotate-local obj 9 #t)) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak2/levels/city/common/traffic-engine-h_REF.gc b/test/decompiler/reference/jak2/levels/city/common/traffic-engine-h_REF.gc index 2f031d38bf..9a0898eeb7 100644 --- a/test/decompiler/reference/jak2/levels/city/common/traffic-engine-h_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/traffic-engine-h_REF.gc @@ -57,8 +57,8 @@ :size-assert #x20 :flag-assert #xb00000020 (:methods - (vis-cell-method-9 (_type_) none 9) - (vis-cell-method-10 (_type_) none 10) + (reset-segment-counts (_type_) none 9) + (debug-draw (_type_) none 10) ) ) @@ -203,11 +203,11 @@ :size-assert #x40 :flag-assert #xe00000040 (:methods - (grid-info-method-9 (_type_ (pointer bounding-box) int int) none 9) - (grid-info-method-10 (_type_ vis-grid-pos vector) none 10) - (grid-info-method-11 (_type_ vis-grid-box vector) none 11) - (grid-info-method-12 (_type_ rgba) none 12) - (grid-info-method-13 (_type_ vis-grid-pos rgba) none 13) + (setup-grid-from-bounding-box (_type_ (pointer bounding-box) int int) none 9) + (lookup-cell-for-point (_type_ vis-grid-pos vector) none 10) + (lookup-box-for-sphere (_type_ vis-grid-box vector) none 11) + (debug-draw-grid (_type_ rgba) none 12) + (debug-draw-cell (_type_ vis-grid-pos rgba) none 13) ) ) @@ -229,28 +229,28 @@ ;; definition of type city-level-info (deftype city-level-info (structure) - ((grid-info grid-info :inline :offset-assert 0) - (cell-array (inline-array vis-cell) :offset-assert 64) - (segment-count int16 :offset-assert 68) - (cell-count uint16 :offset-assert 70) - (segment-array uint32 :offset-assert 72) - (nav-graph nav-graph :offset-assert 76) - (camera-ceiling meters :offset-assert 80) - (pad-array int8 56 :offset-assert 84) + ((grid-info grid-info :inline :offset-assert 0) + (cell-array (inline-array vis-cell) :offset-assert 64) + (segment-count int16 :offset-assert 68) + (cell-count uint16 :offset-assert 70) + (segment-array (inline-array nav-segment) :offset-assert 72) + (nav-graph nav-graph :offset-assert 76) + (camera-ceiling meters :offset-assert 80) + (pad-array int8 56 :offset-assert 84) ) :method-count-assert 19 :size-assert #x8c :flag-assert #x130000008c (:methods (city-level-info-method-9 (_type_) symbol 9) - (city-level-info-method-10 (_type_ vis-ray vector vector) none 10) + (init-vis-ray (_type_ vis-ray vector vector) none 10) (city-level-info-method-11 (_type_ vis-ray) none 11) (city-level-info-method-12 (_type_ vector nav-branch vector) vector 12) - (city-level-info-method-13 (_type_ vector) none 13) - (city-level-info-method-14 (_type_ vis-grid-box) vis-cell 14) - (city-level-info-method-15 (_type_ int int) symbol 15) - (city-level-info-method-16 (_type_ vector int traffic-find-segment-struct (function traffic-find-segment-struct object none)) none 16) - (city-level-info-method-17 (_type_ traffic-engine) none 17) + (lookup-cell-by-position (_type_ vector) vis-cell 13) + (get-first-cell-in-box (_type_ vis-grid-box) vis-cell 14) + (sphere-in-grid? (_type_ int int) symbol 15) + (callback-on-nav-segments-in-sphere (_type_ vector int traffic-find-segment-struct (function traffic-find-segment-struct nav-segment none)) none 16) + (update-suppressions-from-traffic-engine (_type_ traffic-engine) none 17) (city-level-info-method-18 (_type_) none 18) ) ) @@ -287,12 +287,12 @@ :size-assert #x820 :flag-assert #xf00000820 (:methods - (traffic-level-data-method-9 (_type_) none 9) - (traffic-level-data-method-10 (_type_ vis-cell) none 10) - (traffic-level-data-method-11 (_type_ int) none 11) - (traffic-level-data-method-12 (_type_ vis-cell) none 12) - (traffic-level-data-method-13 (_type_) vis-cell 13) - (traffic-level-data-method-14 (_type_) none 14) + (reset (_type_) none 9) + (add-active-cell (_type_ vis-cell) none 10) + (remove-active-cell (_type_ int) none 11) + (add-newly-active-cell (_type_ vis-cell) none 12) + (per-frame-cell-update (_type_) none 13) + (debug-draw (_type_) none 14) ) ) @@ -315,10 +315,10 @@ ;; definition of type traffic-suppression-box (deftype traffic-suppression-box (structure) - ((data uint8 32 :offset-assert 0) - (bbox bounding-box :inline :offset 0) - (flags uint8 :offset 12) - (duration uint32 :offset 28) + ((data uint8 32 :offset-assert 0) + (bbox bounding-box :inline :offset 0) + (flags traffic-suppression-box-flags :offset 12) + (duration uint32 :offset 28) ) :method-count-assert 9 :size-assert #x20 @@ -335,19 +335,19 @@ (format #t "~1Tdata[32] @ #x~X~%" (-> obj bbox)) (format #t "~1Tbbox: #~%" (-> obj bbox)) (format #t "~1Tflags: ~D~%" (-> obj flags)) - (format #t "~1Tduration: ~D~%" (-> obj bbox max w)) + (format #t "~1Tduration: ~D~%" (-> obj duration)) (label cfg-4) obj ) ;; definition of type traffic-guard-type-info (deftype traffic-guard-type-info (structure) - ((object-type uint8 :offset-assert 0) - (max-target-count int8 :offset-assert 1) - (min-target-count int8 :offset-assert 2) - (target-count int8 :offset-assert 3) - (count int8 :offset-assert 4) - (change-to-type uint8 :offset-assert 5) + ((object-type traffic-type :offset-assert 0) + (max-target-count int8 :offset-assert 1) + (min-target-count int8 :offset-assert 2) + (target-count int8 :offset-assert 3) + (count int8 :offset-assert 4) + (change-to-type uint8 :offset-assert 5) ) :method-count-assert 9 :size-assert #x6 @@ -498,7 +498,7 @@ (duration uint32 :offset-assert 16) (start-time time-frame :offset-assert 24) (notify-time time-frame :offset-assert 32) - (alarm-sound-id uint32 :offset-assert 40) + (alarm-sound-id sound-id :offset-assert 40) (target-status-array traffic-target-status 3 :inline :offset-assert 48) (settings traffic-alert-state-settings :inline :offset-assert 288) (guard-type-info-array traffic-guard-type-info 6 :inline :offset-assert 384) @@ -508,7 +508,7 @@ :size-assert #x3d8 :flag-assert #xa000003d8 (:methods - (traffic-alert-state-method-9 (_type_) none 9) + (reset (_type_) none 9) ) ) @@ -604,19 +604,19 @@ ;; definition of type traffic-suppressor (deftype traffic-suppressor (structure) - ((flags uint8 :offset-assert 0) - (bbox bounding-box :inline :offset-assert 16) - (array traffic-suppression-box 16 :inline :offset-assert 48) + ((flags traffic-suppression-flags :offset-assert 0) + (bbox bounding-box :inline :offset-assert 16) + (array traffic-suppression-box 16 :inline :offset-assert 48) ) :method-count-assert 14 :size-assert #x230 :flag-assert #xe00000230 (:methods - (traffic-suppressor-method-9 (_type_) none 9) - (traffic-suppressor-method-10 (_type_ traffic-suppression-params) none 10) - (traffic-suppressor-method-11 (_type_ int) none 11) - (traffic-suppressor-method-12 (_type_ traffic-suppression-params) none 12) - (traffic-suppressor-method-13 (_type_) none 13) + (reset-boxes (_type_) none 9) + (add-new-supression-box (_type_ traffic-suppression-params) none 10) + (remove-box-by-id (_type_ int) none 11) + (update-box-from-params (_type_ traffic-suppression-params) none 12) + (debug-draw (_type_) none 13) ) ) @@ -643,7 +643,7 @@ (active-object-count uint8 :offset-assert 13) (inactive-object-count int8 :offset-assert 14) (active-object-list handle 126 :offset-assert 16) - (active-object-type-list uint8 126 :offset-assert 1024) + (active-object-type-list traffic-type 126 :offset-assert 1024) ) :method-count-assert 27 :size-assert #x47e @@ -652,21 +652,21 @@ (traffic-tracker-method-9 (_type_) none 9) (traffic-tracker-method-10 (_type_) none 10) (traffic-tracker-method-11 (_type_) none 11) - (traffic-tracker-method-12 (_type_ uint handle) none 12) - (traffic-tracker-method-13 (_type_ int) handle 13) - (traffic-tracker-method-14 (_type_ int handle) none 14) - (traffic-tracker-method-15 (_type_ int) handle 15) - (traffic-tracker-method-16 (_type_ int handle) handle 16) - (traffic-tracker-method-17 (_type_ int handle) none 17) - (traffic-tracker-method-18 (_type_ process) none 18) - (traffic-tracker-method-19 (_type_ handle) none 19) - (traffic-tracker-method-20 (_type_ int symbol) none 20) - (traffic-tracker-method-21 (_type_ traffic-object-spawn-params) none 21) - (traffic-tracker-method-22 (_type_ int nav-segment float) none 22) - (traffic-tracker-method-23 (_type_ traffic-object-spawn-params) none 23) - (traffic-tracker-method-24 (_type_ uint traffic-engine) none 24) - (traffic-tracker-method-25 (_type_ (function process-focusable traffic-object-type-info none)) none 25) - (traffic-tracker-method-26 (_type_ int (function process-tree none)) none 26) + (add-active-process (_type_ traffic-type handle) none 12) + (remove-active-process (_type_ int) handle 13) + (add-reserved-process (_type_ traffic-type handle) none 14) + (get-from-inactive-by-type (_type_ traffic-type) handle 15) + (get-from-inactive-by-handle (_type_ traffic-type handle) handle 16) + (deactivate-object (_type_ int symbol) none 17) + (set-process-to-killed (_type_ process) none 18) + (deactivate-all (_type_ symbol) none 19) + (deactivate-all-of-type (_type_ traffic-type symbol) none 20) + (activate-from-params (_type_ traffic-object-spawn-params) none 21) + (activate-by-type (_type_ traffic-type nav-segment float) none 22) + (activate-by-handle (_type_ traffic-object-spawn-params) none 23) + (reset (_type_ uint traffic-engine) none 24) + (for-all-active-processes (_type_ (function process-focusable traffic-object-type-info none)) none 25) + (for-all-active-processes-of-type (_type_ traffic-type (function process-focusable traffic-object-type-info none)) none 26) ) ) @@ -692,7 +692,7 @@ ;; definition of type traffic-engine (deftype traffic-engine (basic) ((object-hash spatial-hash :offset-assert 4) - (manager uint64 :offset-assert 8) + (manager handle :offset-assert 8) (inv-density-factor float :offset-assert 16) (sync-clock uint8 :offset-assert 20) (sync-mask-8 uint8 :offset-assert 21) @@ -704,6 +704,8 @@ (level-data-array traffic-level-data 2 :inline :offset-assert 1040) (object-type-info-array traffic-object-type-info 21 :inline :offset-assert 5200) (tracker-array traffic-tracker 2 :inline :offset-assert 5872) + (citizen-tracker-array traffic-tracker :inline :offset 5872) + (vehicle-tracker-array traffic-tracker :inline :offset 7024) (inactive-object-array handle 420 :offset-assert 8176) (suppressor traffic-suppressor :inline :offset-assert 11536) (danger-sphere-count int8 :offset-assert 12096) @@ -714,33 +716,34 @@ :size-assert #x3050 :flag-assert #x4a00003050 (:methods - (traffic-engine-method-9 (_type_) none 9) - (traffic-engine-method-10 (_type_ process) none 10) - (traffic-engine-method-11 (_type_) none 11) - (traffic-engine-method-12 (_type_) none 12) - (add-object (_type_ int process) none 13) - (traffic-engine-method-14 (_type_ object object) symbol 14) - (traffic-engine-method-15 (_type_ nav-segment float) none 15) - (traffic-engine-method-16 (_type_ nav-segment float) none 16) - (traffic-engine-method-17 (_type_ nav-branch) symbol 17) + (new (symbol type) _type_ 0) + (update-traffic (_type_) none 9) + (reset-and-init-from-manager (_type_ process) none 10) + (stop-alarm-sound (_type_) none 11) + (debug-unused (_type_) none 12) + (add-object (_type_ traffic-type process) none 13) + (sphere-in-loaded-city-infos? (_type_ int vector) symbol 14) + (activate-one-citizen (_type_ nav-segment float) none 15) + (activate-one-vehicle (_type_ nav-segment float) none 16) + (can-dest-be-used? (_type_ nav-branch) symbol 17) (child-killed (_type_ process) none 18) - (traffic-engine-method-19 (_type_ object) none 19) - (traffic-engine-method-20 (_type_ vector vector int) nav-segment 20) - (traffic-engine-method-21 (_type_ vector int traffic-find-segment-struct function) none 21) - (add-danger-sphere (_type_ traffic-danger-info) none 22) - (traffic-engine-method-23 (_type_) none 23) + (deactivate-all-from-level (_type_ symbol) none 19) + (find-best-segment (_type_ vector vector int) nav-segment 20) + (callback-on-nav-segments-in-sphere (_type_ vector int traffic-find-segment-struct (function traffic-find-segment-struct nav-segment none)) none 21) + (add-danger (_type_ traffic-danger-info) none 22) + (guard-count (_type_) int 23) (set-target-level (_type_ float) none 24) (set-guard-target-level (_type_ float) none 25) (deactivate-all (_type_) none 26) - (deactivate-by-type (_type_ int) none 27) - (traffic-engine-method-28 (_type_) symbol 28) + (deactivate-by-type (_type_ traffic-type) none 27) + (maybe-increase-guard-aim-count (_type_) symbol 28) (restore-default-settings (_type_) none 29) - (increase-alert-level (_type_ object target) none 30) - (decrease-alert-level (_type_ object) none 31) - (set-alert-level (_type_ object) none 32) - (set-max-alert-level (_type_ object) none 33) - (set-alert-duration (_type_ object) none 34) - (get-alert-level (_type_) symbol 35) + (increase-alert-level (_type_ int target) none 30) + (decrease-alert-level (_type_ int) none 31) + (set-alert-level (_type_ int) none 32) + (set-max-alert-level (_type_ int) none 33) + (set-alert-duration (_type_ int) none 34) + (get-alert-level (_type_) int 35) (get-target (_type_) target 36) (set-object-target-level (_type_ int float) none 37) (set-object-target-count (_type_ int int) none 38) @@ -748,37 +751,37 @@ (get-object-reserve-count (_type_ int) int 40) (get-object-remaining-count (_type_ int) int 41) (activate-object (_type_ traffic-object-spawn-params) none 42) - (traffic-engine-method-43 (_type_ traffic-object-spawn-params) none 43) - (traffic-engine-method-44 (_type_ int float) none 44) - (traffic-engine-method-45 (_type_) int 45) - (new-suppression-box (_type_ object) none 46) - (traffic-engine-method-47 (_type_ traffic-suppression-params) none 47) + (activate-by-handle (_type_ traffic-object-spawn-params) none 43) + (set-parking-spot-prob (_type_ int float) none 44) + (get-random-parking-spot-type (_type_) traffic-type 45) + (new-suppression-box (_type_ traffic-suppression-params) none 46) + (remove-suppression-box (_type_ traffic-suppression-params) none 47) (update-suppression-box (_type_ traffic-suppression-params) none 48) (traffic-engine-method-49 (_type_ object int traffic-target-status) traffic-target-status 49) - (traffic-engine-method-50 (_type_ process-drawable int) process-focusable 50) - (traffic-engine-method-51 (_type_ (function none)) none 51) - (traffic-engine-method-52 (_type_) none 52) - (end-pursuit-by-type (_type_ int) none 53) + (find-closest-to-with-collide-lists (_type_ process-drawable collide-spec) process-focusable 50) + (for-all-active-processes (_type_ (function process-focusable traffic-object-type-info none)) none 51) + (send-alert-events (_type_) none 52) + (end-pursuit-by-type (_type_ traffic-type) none 53) (get-traffic-guard-type-settings (_type_ int) traffic-guard-type-settings 54) (get-guard-type-for-traffic-obj (_type_ int) uint 55) (get-traffic-guard-change-to-type (_type_ int) uint 56) (set-guard-target-count-range (_type_ int int int) none 57) - (set-object-auto-activate (_type_ object object) none 58) - (traffic-engine-method-59 (_type_ object int) none 59) + (set-object-auto-activate (_type_ int object) none 58) + (debug-check-proc-in-tracker (_type_ process int) none 59) (kill-traffic-sphere (_type_ sphere) none 60) (level-loaded (_type_ level) none 61) (level-killed (_type_ level) none 62) (traffic-engine-method-63 (_type_) none 63) (traffic-engine-method-64 (_type_) none 64) - (traffic-engine-method-65 (_type_ vis-cell) none 65) - (traffic-engine-method-66 (_type_) none 66) - (traffic-engine-method-67 (_type_) none 67) - (traffic-engine-method-68 (_type_) none 68) - (traffic-engine-method-69 (_type_) none 69) - (traffic-engine-method-70 (_type_) none 70) - (traffic-engine-method-71 (_type_) none 71) - (traffic-engine-method-72 (_type_) none 72) - (traffic-engine-method-73 (_type_) none 73) + (handle-new-vis-cell (_type_ vis-cell) none 65) + (update-sync-from-frame-counter (_type_) none 66) + (per-frame-guard-update (_type_) none 67) + (per-frame-activate-deactivate (_type_) none 68) + (per-frame-danger-update (_type_) none 69) + (update-danger-from-target (_type_) none 70) + (per-frame-alert-update (_type_) none 71) + (per-frame-suppressor-update (_type_) none 72) + (recompute-supressions (_type_) none 73) ) ) @@ -801,7 +804,7 @@ (format #t "~1Talert-state: #~%" (-> obj alert-state)) (format #t "~1Tlevel-data-array[2] @ #x~X~%" (-> obj level-data-array)) (format #t "~1Tobject-type-info-array[21] @ #x~X~%" (-> obj object-type-info-array)) - (format #t "~1Ttracker-array[2] @ #x~X~%" (-> obj tracker-array)) + (format #t "~1Ttracker-array[2] @ #x~X~%" (-> obj citizen-tracker-array)) (format #t "~1Tinactive-object-array[420] @ #x~X~%" (-> obj inactive-object-array)) (format #t "~1Tsuppressor: #~%" (-> obj suppressor)) (format #t "~1Tdanger-sphere-count: ~D~%" (-> obj danger-sphere-count)) diff --git a/test/decompiler/reference/jak2/levels/city/common/traffic-engine_REF.gc b/test/decompiler/reference/jak2/levels/city/common/traffic-engine_REF.gc new file mode 100644 index 0000000000..111fc3c76d --- /dev/null +++ b/test/decompiler/reference/jak2/levels/city/common/traffic-engine_REF.gc @@ -0,0 +1,4053 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for symbol *traffic-suppress-activation*, type symbol +(define *traffic-suppress-activation* #f) + +;; definition for symbol *mysql-nav-graph*, type mysql-nav-graph +(define *mysql-nav-graph* (the-as mysql-nav-graph #f)) + +;; definition for symbol *traffic-rigid-body-queue*, type rigid-body-queue +(define *traffic-rigid-body-queue* (new 'static 'rigid-body-queue)) + +;; definition for function get-level-nav-graph-by-id +(defun get-level-nav-graph-by-id ((arg0 int)) + "Get the nav-graph with the given ID from any of the currently loaded levels" + (dotimes (v1-0 (-> *level* length)) + (let ((a1-3 (-> *level* level v1-0))) + (when (= (-> a1-3 status) 'active) + (when (and (!= (-> a1-3 bsp city-level-info) 0) (!= (-> a1-3 bsp city-level-info nav-graph) 0)) + (let ((a1-6 (-> a1-3 bsp city-level-info nav-graph))) + (if (and (!= a1-6 0) (= (-> a1-6 id) arg0)) + (return a1-6) + ) + ) + ) + ) + ) + ) + (the-as nav-graph #f) + ) + +;; definition (debug) for function add-debug-line-arrow +;; WARN: Return type mismatch int vs none. +(defun-debug add-debug-line-arrow () + "Does nothing!" + 0 + (none) + ) + +;; definition for method 10 of type vis-cell +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw vis-cell ((obj vis-cell)) + (dotimes (s5-0 (-> obj segment-count)) + (let ((s4-0 (-> obj segment-array s5-0))) + (add-debug-line + #t + (bucket-id debug2) + (the-as vector (-> s4-0 vertex)) + (-> s4-0 vertex 1) + *color-gray* + #f + (the-as rgba -1) + ) + (add-debug-x #t (bucket-id debug2) (-> s4-0 vertex 1) *color-red*) + ) + ) + 0 + (none) + ) + +;; definition for method 9 of type vis-cell +;; WARN: Return type mismatch int vs none. +(defmethod reset-segment-counts vis-cell ((obj vis-cell)) + (set! (-> obj incoming-segment-count) 0) + (set! (-> obj segment-count) 0) + 0 + (none) + ) + +;; definition for method 9 of type grid-info +;; WARN: Return type mismatch int vs none. +(defmethod setup-grid-from-bounding-box grid-info ((obj grid-info) (arg0 (pointer bounding-box)) (arg1 int) (arg2 int)) + "Set up a grid which fills the given bounding box" + (mem-copy! (the-as pointer (-> obj box)) arg0 32) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (dotimes (a0-2 3) + (set! (-> v1-0 data a0-2) (- (-> obj box max data a0-2) (-> obj box min data a0-2))) + ) + (let ((f0-5 (sqrtf (/ (the float arg1) (* (-> v1-0 x) (-> v1-0 z) (the float arg2)))))) + (let ((a0-6 (min 126 (+ arg1 -1)))) + (set! (-> obj dimension-array 0) (max 1 (min (the int (* f0-5 (-> v1-0 x))) a0-6))) + (set! (-> obj dimension-array 1) arg2) + (set! (-> obj dimension-array 2) (max 1 (min (the int (* f0-5 (-> v1-0 z))) a0-6))) + ) + (let* ((f1-11 (* f0-5 (-> v1-0 z))) + (f1-13 (- f1-11 (the float (the int f1-11)))) + (f0-6 (* f0-5 (-> v1-0 x))) + ) + (cond + ((< f1-13 (- f0-6 (the float (the int f0-6)))) + (if (>= arg1 (* (* (+ (-> obj dimension-array 0) 1) (-> obj dimension-array 1)) (-> obj dimension-array 2))) + (+! (-> obj dimension-array 0) 1) + ) + ) + (else + (if (>= arg1 (* (* (-> obj dimension-array 0) (-> obj dimension-array 1)) (+ (-> obj dimension-array 2) 1))) + (+! (-> obj dimension-array 2) 1) + ) + ) + ) + ) + ) + (dotimes (a0-24 3) + (set! (-> obj axis-scale a0-24) (/ (the float (-> obj dimension-array a0-24)) (-> v1-0 data a0-24))) + (set! (-> obj cell-size data a0-24) (/ (-> v1-0 data a0-24) (the float (-> obj dimension-array a0-24)))) + ) + ) + 0 + (none) + ) + +;; definition for method 10 of type grid-info +;; WARN: Return type mismatch int vs none. +(defmethod lookup-cell-for-point grid-info ((obj grid-info) (arg0 vis-grid-pos) (arg1 vector)) + "Get the grid cell containing the point (or closest, if outside the grid)" + (set! (-> arg0 x) + (max + 0 + (min (the int (* (- (-> arg1 x) (-> obj box min x)) (-> obj axis-scale 0))) (+ (-> obj dimension-array 0) -1)) + ) + ) + (set! (-> arg0 y) + (max + 0 + (min (the int (* (- (-> arg1 y) (-> obj box min y)) (-> obj axis-scale 1))) (+ (-> obj dimension-array 1) -1)) + ) + ) + (set! (-> arg0 z) + (max + 0 + (min (the int (* (- (-> arg1 z) (-> obj box min z)) (-> obj axis-scale 2))) (+ (-> obj dimension-array 2) -1)) + ) + ) + 0 + (none) + ) + +;; definition for method 11 of type grid-info +;; WARN: Return type mismatch int vs none. +(defmethod lookup-box-for-sphere grid-info ((obj grid-info) (arg0 vis-grid-box) (arg1 vector)) + "Get the box of cells containing the given sphere" + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (new 'stack-no-clear 'bounding-box))) + (let ((a0-1 (-> s5-0 min))) + (let ((v1-0 arg1)) + (let ((a1-1 (- (-> arg1 w)))) + (.mov vf6 a1-1) + ) + (.lvf vf4 (&-> v1-0 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a0-1 quad) vf5) + ) + (let ((a0-2 (-> s5-0 max))) + (let ((v1-1 arg1)) + (let ((a1-2 (-> arg1 w))) + (.mov vf6 a1-2) + ) + (.lvf vf4 (&-> v1-1 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a0-2 quad) vf5) + ) + (lookup-cell-for-point obj (-> arg0 min) (-> s5-0 min)) + (lookup-cell-for-point obj (-> arg0 max) (-> s5-0 max)) + ) + 0 + (none) + ) + ) + +;; definition for method 13 of type grid-info +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw-cell grid-info ((obj grid-info) (arg0 vis-grid-pos) (arg1 rgba)) + (let ((v1-0 (new 'stack-no-clear 'bounding-box))) + (dotimes (a3-0 3) + (set! (-> v1-0 min data a3-0) + (+ (-> obj box min data a3-0) (* (the float (-> arg0 data a3-0)) (-> obj cell-size data a3-0))) + ) + ) + (vector+! (-> v1-0 max) (-> v1-0 min) (-> obj cell-size)) + (add-debug-box #t (bucket-id debug2) (-> v1-0 min) (-> v1-0 max) arg1) + ) + 0 + (none) + ) + +;; definition for method 12 of type grid-info +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw-grid grid-info ((obj grid-info) (arg0 rgba)) + (draw-grid (the-as vector (-> obj box)) (-> obj box max) (-> obj dimension-array) arg0) + 0 + (none) + ) + +;; definition for method 9 of type traffic-suppression-params +(defmethod try-creating-new-suppression-box traffic-suppression-params ((obj traffic-suppression-params)) + "Try getting new suppression box, return if it succeeded. ID is stored in the params." + (cond + ((= (-> obj id) -1) + (send-event *traffic-manager* 'new-suppression-box obj) + (!= (-> obj id) -1) + ) + (else + #t + ) + ) + ) + +;; definition for method 10 of type traffic-suppression-params +(defmethod create-or-update-suppression-box traffic-suppression-params ((obj traffic-suppression-params)) + "If the params are already associated with a box, update. Otherwise, attempt to create a new one." + (cond + ((= (-> obj id) -1) + (send-event *traffic-manager* 'new-suppression-box obj) + (!= (-> obj id) -1) + ) + (else + (send-event *traffic-manager* 'update-suppression-box obj) + #t + ) + ) + ) + +;; definition for method 12 of type traffic-suppression-params +;; WARN: Return type mismatch int vs none. +(defmethod kill-suppression-box traffic-suppression-params ((obj traffic-suppression-params)) + "Kill a suppression box, and inform the traffic manager by setting duration to 0." + (when (!= (-> obj id) -1) + (let ((s5-0 (-> obj duration))) + (set! (-> obj duration) (the-as uint 0)) + (send-event *traffic-manager* 'update-suppression-box obj) + (set! (-> obj duration) s5-0) + ) + (set! (-> obj id) -1) + ) + (none) + ) + +;; definition for method 9 of type traffic-suppressor +;; WARN: Return type mismatch int vs none. +(defmethod reset-boxes traffic-suppressor ((obj traffic-suppressor)) + "Clears some flags, mark all boxes as disabled." + (logclear! (-> obj flags) (traffic-suppression-flags tfs0 needs-update)) + (dotimes (v1-2 16) + (let ((a1-3 (-> obj array v1-2))) + (logclear! (-> a1-3 flags) (traffic-suppression-box-flags in-use tfsb1)) + ) + ) + 0 + (none) + ) + +;; definition for method 10 of type traffic-suppressor +;; WARN: Return type mismatch int vs none. +(defmethod add-new-supression-box traffic-suppressor ((obj traffic-suppressor) (arg0 traffic-suppression-params)) + "Create a suppression box for these params. +The param object is updated with the ID of the box and can be later used with update-box-from-params." + (set! (-> arg0 id) -1) + (let ((v1-1 0)) + (b! #t cfg-4 :delay (nop!)) + (label cfg-1) + (let ((a2-2 (-> obj array v1-1))) + (b! (logtest? (-> a2-2 flags) (traffic-suppression-box-flags in-use)) cfg-3 :delay (empty-form)) + (set! (-> arg0 id) v1-1) + (set! (-> a2-2 flags) (traffic-suppression-box-flags in-use)) + ) + (update-box-from-params obj arg0) + (b! #t cfg-6 :delay (nop!)) + (label cfg-3) + (+! v1-1 1) + (label cfg-4) + (b! (< v1-1 16) cfg-1) + ) + (label cfg-6) + 0 + (none) + ) + +;; definition for method 11 of type traffic-suppressor +;; WARN: Return type mismatch int vs none. +(defmethod remove-box-by-id traffic-suppressor ((obj traffic-suppressor) (arg0 int)) + "Remove a box that was previously added, by its ID." + (when (!= arg0 -1) + (logior! (-> obj flags) (traffic-suppression-flags needs-update)) + (let ((v1-6 (-> obj array arg0))) + (logclear! (-> v1-6 flags) (traffic-suppression-box-flags in-use)) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type traffic-suppressor +;; WARN: Return type mismatch int vs none. +(defmethod update-box-from-params traffic-suppressor ((obj traffic-suppressor) (arg0 traffic-suppression-params)) + "Update a box that was previously added" + (let ((v1-0 (-> arg0 id))) + (when (!= v1-0 -1) + (logior! (-> obj flags) (traffic-suppression-flags needs-update)) + (let* ((s5-0 (-> obj array v1-0)) + (s4-1 (logior (-> s5-0 flags) (traffic-suppression-box-flags tfsb1))) + ) + (mem-copy! (the-as pointer (-> s5-0 bbox)) (the-as pointer (-> arg0 bbox)) 32) + (set! (-> s5-0 duration) (-> arg0 duration)) + (set! (-> s5-0 flags) s4-1) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 13 of type traffic-suppressor +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw traffic-suppressor ((obj traffic-suppressor)) + (let ((s5-0 (new 'stack-no-clear 'bounding-box))) + (new 'stack-no-clear 'vector4w) + (let ((s4-0 *color-red*)) + (dotimes (s3-0 16) + (let ((v1-3 (-> obj array s3-0))) + (when (logtest? (-> v1-3 flags) (traffic-suppression-box-flags in-use)) + (set! (-> s5-0 min quad) (-> v1-3 bbox min quad)) + (set! (-> s5-0 max quad) (-> v1-3 bbox max quad)) + (set! (-> s5-0 min w) 1.0) + (set! (-> s5-0 max w) 1.0) + (add-debug-box #t (bucket-id debug-no-zbuf1) (-> s5-0 min) (-> s5-0 max) s4-0) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 25 of type traffic-tracker +;; WARN: Return type mismatch int vs none. +(defmethod for-all-active-processes traffic-tracker ((obj traffic-tracker) (arg0 (function process-focusable traffic-object-type-info none))) + "Call the given function on all active processes." + (let ((s4-0 (-> obj traffic))) + (countdown (s3-0 (-> obj active-object-count)) + (let ((a1-1 (-> s4-0 object-type-info-array (-> obj active-object-type-list s3-0))) + (a0-2 (handle->process (-> obj active-object-list s3-0))) + ) + (if (not (logtest? (-> (the-as process-focusable a0-2) focus-status) (focus-status inactive))) + (arg0 (the-as process-focusable a0-2) a1-1) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 26 of type traffic-tracker +;; WARN: Return type mismatch int vs none. +(defmethod for-all-active-processes-of-type traffic-tracker ((obj traffic-tracker) (arg0 traffic-type) (arg1 (function process-focusable traffic-object-type-info none))) + "Call the given function on all active processes matching the given type." + (let ((s3-0 (-> obj traffic))) + (countdown (s2-0 (-> obj active-object-count)) + (let ((a0-1 (-> obj active-object-type-list s2-0))) + (when (= a0-1 arg0) + (let ((a1-1 (-> s3-0 object-type-info-array a0-1)) + (a0-3 (handle->process (-> obj active-object-list s2-0))) + ) + (if (not (logtest? (-> (the-as process-focusable a0-3) focus-status) (focus-status inactive))) + (arg1 (the-as process-focusable a0-3) a1-1) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type traffic-tracker +;; WARN: Return type mismatch int vs none. +(defmethod add-active-process traffic-tracker ((obj traffic-tracker) (arg0 traffic-type) (arg1 handle)) + "Add a process as active." + (let ((v1-0 (-> obj active-object-count))) + (when (< v1-0 (the-as uint 126)) + (set! (-> obj active-object-list v1-0) arg1) + (set! (-> obj active-object-type-list v1-0) arg0) + (+! (-> obj active-object-count) 1) + (let ((v1-6 (-> obj traffic object-type-info-array arg0))) + (+! (-> v1-6 active-count) 1) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 13 of type traffic-tracker +(defmethod remove-active-process traffic-tracker ((obj traffic-tracker) (arg0 int)) + "Remove a process from the tracking list." + (let ((v0-0 (-> obj active-object-list arg0))) + (let ((v1-3 (-> obj active-object-type-list arg0)) + (a2-1 (+ (-> obj active-object-count) -1)) + ) + (when (>= a2-1 0) + (set! (-> obj active-object-list arg0) (-> obj active-object-list a2-1)) + (set! (-> obj active-object-type-list arg0) (-> obj active-object-type-list a2-1)) + (+! (-> obj active-object-count) -1) + (let ((v1-6 (-> obj traffic object-type-info-array v1-3))) + (+! (-> v1-6 active-count) -1) + ) + ) + ) + v0-0 + ) + ) + +;; definition for method 14 of type traffic-tracker +;; WARN: Return type mismatch int vs none. +(defmethod add-reserved-process traffic-tracker ((obj traffic-tracker) (arg0 traffic-type) (arg1 handle)) + "Add a process to the reserve list for a type. This process is allocated, but not yet activated." + (let* ((v1-2 (-> obj traffic object-type-info-array arg0)) + (a1-2 (-> v1-2 inactive-count)) + ) + (when (< a1-2 20) + (set! (-> v1-2 array a1-2) arg1) + (+! (-> v1-2 inactive-count) 1) + (+! (-> v1-2 reserve-count) 1) + (+! (-> obj inactive-object-count) 1) + ) + ) + 0 + (none) + ) + +;; definition for method 15 of type traffic-tracker +(defmethod get-from-inactive-by-type traffic-tracker ((obj traffic-tracker) (arg0 traffic-type)) + "Get any handle from the inactive list of this type, and remove it from the list." + (let ((v1-2 (-> obj traffic object-type-info-array arg0)) + (a1-2 0) + (v0-0 (the-as handle #f)) + ) + (let ((a2-1 (+ (-> v1-2 inactive-count) -1))) + (when (>= a2-1 0) + (set! v0-0 (-> v1-2 array a1-2)) + (set! (-> v1-2 array a1-2) (-> v1-2 array a2-1)) + (+! (-> v1-2 inactive-count) -1) + (+! (-> v1-2 reserve-count) -1) + (+! (-> obj inactive-object-count) -1) + ) + ) + v0-0 + ) + ) + +;; definition for method 16 of type traffic-tracker +(defmethod get-from-inactive-by-handle traffic-tracker ((obj traffic-tracker) (arg0 traffic-type) (arg1 handle)) + "Remove the given handle from the inactive list of the given type." + (let ((v1-2 (-> obj traffic object-type-info-array arg0)) + (v0-0 (the-as handle #f)) + ) + (let* ((a3-0 (+ (-> v1-2 inactive-count) -1)) + (a1-3 a3-0) + ) + (while (and (>= a1-3 0) (!= (-> v1-2 array a1-3) arg1)) + (+! a1-3 -1) + ) + (when (>= a1-3 0) + (set! v0-0 (-> v1-2 array a1-3)) + (set! (-> v1-2 array a1-3) (-> v1-2 array a3-0)) + (+! (-> v1-2 inactive-count) -1) + (+! (-> obj inactive-object-count) -1) + ) + ) + v0-0 + ) + ) + +;; definition for method 17 of type traffic-tracker +;; WARN: Return type mismatch int vs none. +(defmethod deactivate-object traffic-tracker ((obj traffic-tracker) (arg0 int) (arg1 symbol)) + "Send a traffic-off event (or traffic-off-force) to deactivate an object, specified by index in active object array. +Process is recycled and moved to reserved, if it deactivates." + (with-pp + (let* ((s3-0 (-> obj active-object-type-list arg0)) + (gp-0 'traffic-off) + (s2-0 (remove-active-process obj arg0)) + (s1-0 (handle->process s2-0)) + (v1-5 (the-as object #t)) + ) + (when s1-0 + (when (not (logtest? (-> (the-as process-focusable s1-0) focus-status) (focus-status inactive))) + (if arg1 + (set! gp-0 'traffic-off-force) + ) + (let ((a1-2 (new 'stack-no-clear 'event-message-block))) + (set! (-> a1-2 from) (process->ppointer pp)) + (set! (-> a1-2 num-params) 0) + (set! (-> a1-2 message) gp-0) + (set! v1-5 (send-event-function s1-0 a1-2)) + ) + ) + (cond + (v1-5 + (add-reserved-process obj s3-0 s2-0) + ) + (else + (add-active-process obj s3-0 s2-0) + (when *debug-segment* + (when arg1 + (format 0 "traffic-engine::deactivate-object: ~s event refused~%" gp-0) + (format 0 "obj ~s~%" s1-0) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 18 of type traffic-tracker +;; WARN: Return type mismatch int vs none. +(defmethod set-process-to-killed traffic-tracker ((obj traffic-tracker) (arg0 process)) + "Move from active to killed. Separate from reserve." + (let ((v1-0 -1)) + (let ((a0-1 (process->ppointer arg0))) + (b! (not a0-1) cfg-4 :delay (nop!)) + (let ((a1-3 (new 'static 'handle :pid (-> a0-1 0 pid)))) + (b! #t cfg-5 :delay (nop!)) + (label cfg-4) + (set! a1-3 (new 'static 'handle)) + (label cfg-5) + (let ((a0-3 (logior a1-3 (new 'static 'handle :process a0-1))) + (a1-4 (-> obj active-object-count)) + ) + (b! #t cfg-8 :delay (nop!)) + (label cfg-6) + (+! a1-4 -1) + (b! (!= (-> obj active-object-list a1-4) a0-3) cfg-8 :delay (empty-form)) + (set! v1-0 (the-as int a1-4)) + (b! #t cfg-10 :delay (nop!)) + (label cfg-8) + (b! (nonzero? a1-4) cfg-6 :delay (nop!)) + ) + ) + ) + (label cfg-10) + (when (!= v1-0 -1) + (let ((s5-0 (-> obj active-object-type-list v1-0))) + (let ((a2-4 (remove-active-process obj v1-0))) + (add-reserved-process obj s5-0 a2-4) + ) + (let ((v1-5 (-> obj traffic object-type-info-array s5-0))) + (+! (-> v1-5 killed-count) 1) + (+! (-> v1-5 reserve-count) -1) + ) + ) + #t + ) + ) + 0 + (none) + ) + +;; definition for method 20 of type traffic-tracker +;; WARN: Return type mismatch int vs none. +(defmethod deactivate-all-of-type traffic-tracker ((obj traffic-tracker) (arg0 traffic-type) (arg1 symbol)) + "Deactivate all processes of given type" + (countdown (s3-0 (-> obj active-object-count)) + (if (= (-> obj active-object-type-list s3-0) arg0) + (deactivate-object obj (the-as int s3-0) arg1) + ) + ) + 0 + (none) + ) + +;; definition for method 19 of type traffic-tracker +;; WARN: Return type mismatch int vs none. +(defmethod deactivate-all traffic-tracker ((obj traffic-tracker) (arg0 symbol)) + "Deactivate all processes that are tracked" + (countdown (s4-0 (-> obj active-object-count)) + (deactivate-object obj (the-as int s4-0) arg0) + ) + 0 + (none) + ) + +;; definition for method 21 of type traffic-tracker +;; WARN: Return type mismatch int vs none. +(defmethod activate-from-params traffic-tracker ((obj traffic-tracker) (arg0 traffic-object-spawn-params)) + "Get a reserved process, and activate with the given params." + (local-vars (sv-16 handle)) + (let ((gp-0 (-> arg0 object-type))) + (set! (-> arg0 proc) #f) + (let ((v1-2 (-> obj traffic object-type-info-array gp-0))) + (when (and (> (-> v1-2 inactive-count) 0) (> (-> v1-2 reserve-count) 0)) + (set! sv-16 (get-from-inactive-by-type obj gp-0)) + (let ((s3-0 (handle->process sv-16))) + (when s3-0 + (cond + ((send-event s3-0 'traffic-activate arg0 (-> obj traffic)) + (set! (-> arg0 proc) s3-0) + (add-active-process obj gp-0 sv-16) + 0 + ) + (else + (add-reserved-process obj gp-0 sv-16) + ) + ) + ) + ) + 0 + ) + ) + ) + 0 + (none) + ) + +;; definition for method 22 of type traffic-tracker +;; WARN: Return type mismatch int vs none. +(defmethod activate-by-type traffic-tracker ((obj traffic-tracker) (arg0 traffic-type) (arg1 nav-segment) (arg2 float)) + "If possible, activate a process of the given type." + (let ((v1-2 (-> obj traffic object-type-info-array arg0))) + (when (and (> (-> v1-2 inactive-count) 0) + (> (-> v1-2 reserve-count) 0) + (< (-> v1-2 active-count) (-> v1-2 target-count)) + (logtest? (-> v1-2 flags) 4) + (logtest? (-> v1-2 flags) 8) + (or (not (logtest? (-> v1-2 flags) 1)) + (zero? (logand (-> obj traffic alert-state flags) (traffic-alert-flag alert-ending))) + ) + ) + (let ((s4-0 (new 'stack-no-clear 'mystery-traffic-object-spawn-params))) + (let ((s2-0 (-> arg1 branch))) + (set! (-> s4-0 params object-type) arg0) + (set! (-> s4-0 params guard-type) (-> v1-2 guard-type)) + (set! (-> s4-0 params nav-branch) s2-0) + (let ((v1-4 s2-0)) + (set! (-> s4-0 vector 2 x) (* 1024.0 (the float (-> v1-4 speed-limit)))) + ) + (vector-! (the-as vector (-> s4-0 vector)) (-> arg1 vertex 1) (the-as vector (-> arg1 vertex))) + (vector-normalize! (the-as vector (-> s4-0 vector)) 1.0) + (vector+float*! + (-> s4-0 params position) + (the-as vector (-> arg1 vertex)) + (the-as vector (-> s4-0 vector)) + arg2 + ) + (let ((f0-6 (* (+ -0.5 (rand-vu)) (* 256.0 (the float (-> s2-0 width)))))) + (+! (-> s4-0 params position x) (* -1.0 (-> s4-0 vector 0 z) f0-6)) + (+! (-> s4-0 params position z) (* (-> s4-0 vector 0 x) f0-6)) + ) + ) + (set! (-> s4-0 vector 2 y) + (+ (* 0.5 (-> s4-0 vector 2 x)) (* (-> obj rand) (-> obj traffic inv-density-factor) (-> arg1 spawn-spacing))) + ) + (vector-float*! (-> s4-0 params velocity) (the-as vector (-> s4-0 vector)) (-> s4-0 vector 2 x)) + (vector-float*! (-> s4-0 vector 1) (the-as vector (-> s4-0 vector)) (-> s4-0 vector 2 y)) + (when (not (sphere-hash-method-32 (-> obj object-hash) (-> s4-0 params position) (-> s4-0 vector 1) 20480.0 -1)) + (set! (-> s4-0 params behavior) (the-as uint 2)) + (set! (-> s4-0 params nav-mesh) #f) + (-> arg1 nav-mesh-id) + (if (= (-> arg1 tracker-id) 1) + (set! (-> s4-0 params nav-mesh) (get-nav-mesh (the-as actor-id (-> arg1 nav-mesh-id)))) + ) + (forward-up-nopitch->quaternion + (-> s4-0 params rotation) + (the-as vector (-> s4-0 vector)) + (new 'static 'vector :y 1.0 :w 1.0) + ) + (set! (-> obj rand) (rand-vu)) + (activate-from-params obj (-> s4-0 params)) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 23 of type traffic-tracker +;; WARN: Return type mismatch int vs none. +(defmethod activate-by-handle traffic-tracker ((obj traffic-tracker) (arg0 traffic-object-spawn-params)) + "Activate, using the handle in the params." + (local-vars (sv-16 handle)) + (let ((gp-0 (-> arg0 object-type))) + (set! (-> arg0 proc) #f) + (when (> (-> obj traffic object-type-info-array gp-0 inactive-count) 0) + (set! sv-16 (get-from-inactive-by-handle obj gp-0 (the-as handle (-> arg0 handle)))) + (let ((s3-0 (handle->process sv-16))) + (when s3-0 + (cond + ((send-event s3-0 'traffic-activate arg0 (-> obj traffic)) + (set! (-> arg0 proc) s3-0) + (add-active-process obj gp-0 sv-16) + 0 + ) + (else + (add-reserved-process obj gp-0 sv-16) + ) + ) + ) + ) + 0 + ) + ) + 0 + (none) + ) + +;; definition for method 9 of type traffic-level-data +;; WARN: Return type mismatch int vs none. +(defmethod reset traffic-level-data ((obj traffic-level-data)) + (set! (-> obj city-info) (the-as city-level-info 0)) + (set! (-> obj active-cell-count) (the-as uint 0)) + (set! (-> obj newly-active-cell-count) (the-as uint 0)) + 0 + (none) + ) + +;; definition for method 24 of type traffic-tracker +;; WARN: Return type mismatch int vs none. +(defmethod reset traffic-tracker ((obj traffic-tracker) (arg0 uint) (arg1 traffic-engine)) + (set! (-> obj traffic) arg1) + (set! (-> obj object-hash) (-> arg1 object-hash)) + (set! (-> obj rand) 0.5) + (set! (-> obj id) arg0) + (set! (-> obj active-object-count) (the-as uint 0)) + (set! (-> obj inactive-object-count) 0) + 0 + (none) + ) + +;; definition for method 9 of type traffic-alert-state +;; WARN: Return type mismatch int vs none. +(defmethod reset traffic-alert-state ((obj traffic-alert-state)) + (set! (-> obj flags) (traffic-alert-flag)) + (set! (-> obj level) (the-as uint 0)) + (set! (-> obj duration) (the-as uint 9000)) + (set! (-> obj alarm-sound-id) (new-sound-id)) + (set! (-> obj guard-inaccuracy-factor) 1.0) + (dotimes (v1-2 3) + (let ((a0-4 (-> obj target-status-array v1-2))) + (set! (-> a0-4 flags) (traffic-target-flag)) + (set! (-> a0-4 handle) (the-as handle #f)) + ) + ) + (set! (-> obj guard-type-info-array 0 object-type) (traffic-type crimson-guard-1)) + (set! (-> obj guard-type-info-array 1 object-type) (traffic-type crimson-guard-1)) + (set! (-> obj guard-type-info-array 2 object-type) (traffic-type crimson-guard-1)) + (set! (-> obj guard-type-info-array 3 object-type) (traffic-type crimson-guard-2)) + (set! (-> obj guard-type-info-array 4 object-type) (traffic-type guard-bike)) + (set! (-> obj guard-type-info-array 5 object-type) (traffic-type hellcat)) + (dotimes (v1-11 21) + (set! (-> obj guard-type-mask-from-object-type v1-11) (the-as uint 0)) + ) + (dotimes (v1-14 6) + (let ((a0-10 (-> obj guard-type-info-array v1-14 object-type))) + (set! (-> obj guard-type-mask-from-object-type a0-10) + (the-as uint (logior (ash 1 v1-14) (-> obj guard-type-mask-from-object-type a0-10))) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 10 of type traffic-engine +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod reset-and-init-from-manager traffic-engine ((obj traffic-engine) (arg0 process)) + "Reset the traffic engine" + (set! (-> obj manager) (process->handle arg0)) + (set! (-> obj flags) (the-as uint 0)) + (set! (-> obj danger-sphere-count) 0) + (set! (-> *game-info* wanted-flash) #f) + (let ((v1-4 (-> obj inactive-object-array))) + (dotimes (a0-5 21) + (let ((a1-3 (-> obj object-type-info-array a0-5))) + (set! (-> a1-3 flags) (the-as uint 6)) + (set! (-> a1-3 inactive-count) 0) + (set! (-> a1-3 active-count) 0) + (set! (-> a1-3 target-count) 20) + (set! (-> a1-3 reserve-count) (the-as uint #x7d00)) + (set! (-> a1-3 killed-count) (the-as uint 0)) + (set! (-> a1-3 array) v1-4) + (set! (-> a1-3 level) #f) + ) + (set! v1-4 (&-> v1-4 20)) + ) + ) + (set! (-> obj object-type-info-array 6 guard-type) (the-as uint 0)) + (set! (-> obj object-type-info-array 20 level) (the-as level 'ctywide)) + (let ((v1-8 11)) + (dotimes (a0-6 10) + (set! (-> obj object-type-info-array v1-8 tracker-index) (the-as uint 0)) + (+! v1-8 1) + ) + ) + (let ((v1-11 0)) + (dotimes (a0-7 11) + (set! (-> obj object-type-info-array v1-11 tracker-index) (the-as uint 1)) + (+! v1-11 1) + ) + ) + (dotimes (s5-0 2) + (reset (-> obj tracker-array s5-0) (the-as uint s5-0) obj) + ) + (reset-boxes (-> obj suppressor)) + (set! (-> obj object-hash object-count) 0) + (let* ((v1-24 (-> obj object-hash)) + (a0-15 + (/ (+ (* (* (* (-> v1-24 dimension-array 0) (-> v1-24 dimension-array 1)) (-> v1-24 dimension-array 2)) + (-> v1-24 bucket-size) + ) + 15 + ) + 16 + ) + ) + (v1-25 (the-as (pointer uinteger) (-> v1-24 bucket-array))) + ) + (while (nonzero? a0-15) + (+! a0-15 -1) + (set! (-> (the-as (pointer uint128) v1-25) 0) (the-as uint128 0)) + (set! v1-25 (&-> (the-as (pointer grid-hash-word) v1-25) 16)) + ) + ) + 0 + (dotimes (s5-1 2) + (reset (-> obj level-data-array s5-1)) + ) + (dotimes (s5-2 (-> *level* length)) + (let ((a1-12 (-> *level* level s5-2))) + (if (= (-> a1-12 status) 'active) + (level-loaded obj a1-12) + ) + ) + ) + (reset (-> obj alert-state)) + 0 + (none) + ) + +;; definition for method 11 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod stop-alarm-sound traffic-engine ((obj traffic-engine)) + (sound-stop (-> obj alert-state alarm-sound-id)) + 0 + (none) + ) + +;; definition for method 61 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod level-loaded traffic-engine ((obj traffic-engine) (arg0 level)) + "Call after loading a level to patch the data in the bsp" + (format #t "traffic-engine: level birth ~S~%" (-> arg0 nickname)) + (cond + ((or (not *debug-segment*) + (not (and (get-nav-graph-editor) (= (-> (get-nav-graph-editor) nav-graph nav_graph_id) 1))) + ) + (when (and (nonzero? (-> arg0 bsp city-level-info)) (nonzero? (-> arg0 bsp city-level-info nav-graph))) + (let ((s4-0 (-> arg0 bsp city-level-info))) + (let ((v1-13 (-> arg0 bsp city-level-info nav-graph))) + (when (not (-> v1-13 patched)) + (dotimes (a0-8 (the-as int (-> s4-0 cell-count))) + (let ((a1-3 (-> s4-0 cell-array a0-8))) + (set! (-> a1-3 segment-array) + (the-as (inline-array nav-segment) (-> s4-0 segment-array (the-as int (the-as uint (-> a1-3 segment-array))))) + ) + ) + ) + (dotimes (a0-11 (-> s4-0 segment-count)) + (let ((a1-6 (-> s4-0 segment-array a0-11))) + (set! (-> a1-6 branch) (-> v1-13 branch-array (the-as uint (-> a1-6 branch)))) + ) + ) + (dotimes (a0-14 (-> v1-13 node-count)) + (let ((a1-9 (-> v1-13 node-array a0-14))) + (set! (-> a1-9 branch-array) + (the-as (inline-array nav-branch) (-> v1-13 branch-array (the-as uint (-> a1-9 branch-array)))) + ) + ) + ) + (dotimes (a0-17 (-> v1-13 branch-count)) + (let* ((a1-12 (-> v1-13 branch-array a0-17)) + (t0-1 (the-as object (-> a1-12 src-node))) + (a2-12 (the-as object (-> a1-12 dest-node))) + ) + (set! (-> a1-12 src-node) (-> v1-13 node-array (the-as uint t0-1))) + (cond + ((< #x186a0 (the-as int a2-12)) + (let ((a2-13 (- (the-as uint #xffffffff) (the-as uint a2-12)))) + (set! (-> a1-12 dest-node) (-> v1-13 link-array a2-13 dummy-node)) + ) + ) + (else + (set! (-> a1-12 dest-node) (-> v1-13 node-array (the-as uint a2-12))) + ) + ) + ) + ) + (set! (-> v1-13 patched) #t) + ) + (dotimes (a0-21 (-> v1-13 branch-count)) + (set! (-> v1-13 branch-array a0-21 user-count) (the-as uint 0)) + 0 + ) + ) + (dotimes (v1-16 (the-as int (-> s4-0 cell-count))) + (let ((a0-23 (-> s4-0 cell-array v1-16))) + (set! (-> a0-23 flags) (vis-cell-flag)) + (set! (-> a0-23 prev-flags) (vis-cell-flag)) + ) + 0 + ) + (let ((s3-0 0)) + (dotimes (s2-0 (-> s4-0 segment-count)) + (let ((s1-0 (-> s4-0 segment-array s2-0))) + (vector-vector-distance (the-as vector (-> s1-0 vertex)) (-> s1-0 vertex 1)) + (when (< (-> s1-0 spawn-spacing) 0.0) + (inspect s1-0) + #t + (+! s3-0 1) + (set! (-> s1-0 spawn-spacing) (fabs (-> s1-0 spawn-spacing))) + ) + ) + ) + (format #t "birth-level ~s found ~d bad segs~%" arg0 s3-0) + ) + ) + ) + ) + (else + 0 + ) + ) + (let ((s4-1 (the-as traffic-level-data #f))) + (dotimes (v1-31 2) + (let ((a0-34 (-> obj level-data-array v1-31))) + (if (zero? (-> a0-34 city-info)) + (set! s4-1 a0-34) + ) + ) + ) + (if (not s4-1) + (format 0 "level-data not found~%") + ) + (when s4-1 + (set! (-> s4-1 city-info) (-> arg0 bsp city-level-info)) + (set! (-> s4-1 active-cell-count) (the-as uint 0)) + 0 + ) + ) + (dotimes (gp-1 (-> *level* length)) + (let ((v1-43 (-> *level* level gp-1))) + (when (= (-> v1-43 status) 'active) + (when (nonzero? (-> v1-43 bsp city-level-info)) + (let ((s5-1 (-> v1-43 bsp city-level-info nav-graph))) + (when (and (nonzero? s5-1) (-> s5-1 patched)) + (dotimes (s4-2 (-> s5-1 link-count)) + (let ((s3-1 (-> s5-1 link-array s4-2))) + (when (not (-> s3-1 dest-graph)) + (let ((s2-1 (get-level-nav-graph-by-id (the-as int (-> s3-1 dest-graph-id))))) + (when (and s2-1 (-> s2-1 patched)) + (dotimes (s1-1 (-> s2-1 node-count)) + (when (= (-> s3-1 dest-node-id) (-> s2-1 node-array s1-1 id)) + (set! (-> s3-1 dest-graph) s2-1) + (set-dst-node (-> s5-1 branch-array (-> s3-1 src-branch-id)) (-> s2-1 node-array s1-1)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 62 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod level-killed traffic-engine ((obj traffic-engine) (arg0 level)) + "Call after removing a level. Kills processes and unlinks nav" + (let ((s4-0 (-> arg0 bsp city-level-info nav-graph))) + (dotimes (v1-2 2) + (let ((a0-4 (-> obj level-data-array v1-2))) + (when (= (-> a0-4 city-info) (-> arg0 bsp city-level-info)) + (set! (-> a0-4 city-info) (the-as city-level-info 0)) + 0 + ) + ) + ) + (when (nonzero? s4-0) + (dotimes (s3-0 (-> *level* length)) + (let ((v1-9 (-> *level* level s3-0))) + (when (= (-> v1-9 status) 'active) + (when (and (!= arg0 v1-9) (!= (-> v1-9 bsp city-level-info) 0)) + (let ((s2-0 (-> v1-9 bsp city-level-info nav-graph))) + (when (nonzero? s2-0) + (dotimes (s1-0 (-> s2-0 link-count)) + (let ((s0-0 (-> s2-0 link-array s1-0))) + (when (= (-> s0-0 dest-graph) s4-0) + (set! (-> s0-0 dest-graph) (get-level-nav-graph-by-id (the-as int (-> s0-0 dest-graph-id)))) + (when (-> s0-0 dest-graph) + (set-dst-node (-> s2-0 branch-array (-> s0-0 src-branch-id)) (-> s0-0 dummy-node)) + (set! (-> s0-0 dest-graph) #f) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (let ((s4-1 (-> arg0 bsp city-level-info nav-graph))) + (dotimes (s3-1 (-> s4-1 link-count)) + (let ((s2-1 (-> s4-1 link-array s3-1))) + (set-dst-node (-> s4-1 branch-array (-> s2-1 src-branch-id)) (-> s2-1 dummy-node)) + (set! (-> s2-1 dest-graph) #f) + ) + ) + ) + (deactivate-all-from-level obj (-> arg0 name)) + 0 + (none) + ) + +;; definition for method 51 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod for-all-active-processes traffic-engine ((obj traffic-engine) (arg0 (function process-focusable traffic-object-type-info none))) + (dotimes (s4-0 2) + (for-all-active-processes (-> obj tracker-array s4-0) arg0) + ) + 0 + (none) + ) + +;; definition for method 13 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod add-object traffic-engine ((obj traffic-engine) (arg0 traffic-type) (arg1 process)) + (add-reserved-process + (-> obj tracker-array (-> obj object-type-info-array arg0 tracker-index)) + arg0 + (process->handle arg1) + ) + 0 + (none) + ) + +;; definition for method 18 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod child-killed traffic-engine ((obj traffic-engine) (arg0 process)) + "handle killing a child process" + (cond + ((type? arg0 citizen) + (set-process-to-killed (-> obj vehicle-tracker-array) arg0) + ) + ((type? arg0 vehicle) + (set-process-to-killed (-> obj citizen-tracker-array) arg0) + ) + (else + 0 + ) + ) + 0 + (none) + ) + +;; definition for method 15 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod activate-one-citizen traffic-engine ((obj traffic-engine) (arg0 nav-segment) (arg1 float)) + (let ((a1-1 (+ (rand-vu-int-count 10) 11))) + (activate-by-type (-> obj citizen-tracker-array) (the-as traffic-type a1-1) arg0 arg1) + ) + 0 + (none) + ) + +;; definition for method 16 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod activate-one-vehicle traffic-engine ((obj traffic-engine) (arg0 nav-segment) (arg1 float)) + (let ((a1-1 0)) + (dotimes (v1-0 11) + (if (zero? (-> obj object-type-info-array v1-0 inactive-count)) + (set! a1-1 (logior a1-1 (ash 1 v1-0))) + ) + ) + (let ((a1-2 (rand-vu-int-count-excluding 11 a1-1))) + (activate-by-type (-> obj vehicle-tracker-array) (the-as traffic-type a1-2) arg0 arg1) + ) + ) + 0 + (none) + ) + +;; definition for method 65 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod handle-new-vis-cell traffic-engine ((obj traffic-engine) (arg0 vis-cell)) + (dotimes (s4-0 (-> arg0 segment-count)) + (let* ((s3-0 (-> arg0 segment-array s4-0)) + (s1-0 (-> s3-0 tracker-id)) + ) + (when (and (logtest? (logxor (-> arg0 flags) (the-as uint (-> arg0 prev-flags))) (ash 1 s1-0)) + (and (not (logtest? (-> arg0 flags) (vis-cell-flag suppress))) + (not (or (can-dest-be-used? obj (-> s3-0 branch)) (let ((a0-7 (-> s3-0 branch))) + (>= (-> a0-7 user-count) (-> a0-7 max-user-count)) + ) + ) + ) + ) + ) + (let* ((s2-0 (-> obj tracker-array s1-0)) + (f30-0 (* (-> s2-0 rand) (-> obj inv-density-factor) (-> s3-0 spawn-spacing))) + ) + (cond + ((= s1-0 1) + (when (nonzero? (-> s3-0 nav-mesh-id)) + (while (and (< f30-0 (-> s3-0 length)) (> (-> s2-0 inactive-object-count) 0)) + (activate-one-vehicle obj s3-0 f30-0) + (set! f30-0 (+ 24576.0 (* (-> s2-0 rand) (-> obj inv-density-factor) (-> s3-0 spawn-spacing)) f30-0)) + ) + ) + ) + (else + (while (and (< f30-0 (-> s3-0 length)) (> (-> s2-0 inactive-object-count) 0)) + (activate-one-citizen obj s3-0 f30-0) + (set! f30-0 (+ 49152.0 (* (-> s2-0 rand) (-> obj inv-density-factor) (-> s3-0 spawn-spacing)) f30-0)) + ) + ) + ) + (if (>= f30-0 (-> s3-0 length)) + (set! (-> s2-0 rand) + (fmax 0.0 (- (-> s2-0 rand) (/ (-> s3-0 length) (* (-> s3-0 spawn-spacing) (-> obj inv-density-factor))))) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 14 of type traffic-level-data +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod debug-draw traffic-level-data ((obj traffic-level-data)) + (local-vars (sv-16 nav-node) (sv-20 nav-branch) (sv-80 nav-node) (sv-84 vector) (sv-88 vector) (sv-92 vector)) + (when (and (nonzero? (-> obj city-info)) (nonzero? (-> obj city-info nav-graph))) + (let ((s5-0 (-> obj city-info nav-graph))) + (let ((v1-6 (-> s5-0 node-array 0))) + (countdown (a0-3 (-> s5-0 node-count)) + (logclear! (-> v1-6 flags) (nav-node-flag-byte visited)) + (&+! v1-6 32) + ) + ) + (dotimes (s4-0 (the-as int (-> obj active-cell-count))) + (let ((a0-4 (-> obj active-cell-list s4-0))) + (dotimes (v1-11 (-> a0-4 segment-count)) + (let ((a1-5 (-> a0-4 segment-array v1-11 branch src-node))) + (logior! (-> a1-5 flags) (nav-node-flag-byte visited)) + ) + ) + (debug-draw a0-4) + ) + ) + (set! sv-16 (-> s5-0 node-array 0)) + (countdown (gp-1 (-> s5-0 node-count)) + (when (logtest? (-> sv-16 flags) (nav-node-flag-byte visited)) + (debug-draw sv-16) + (dotimes (s5-1 (-> sv-16 branch-count)) + (set! sv-20 (-> sv-16 branch-array s5-1)) + (set! sv-80 (-> sv-20 dest-node)) + (set! sv-84 (new 'stack-no-clear 'vector)) + (set! sv-88 (new 'stack-no-clear 'vector)) + (set! sv-92 (new 'stack-no-clear 'vector)) + (let ((a1-7 sv-16) + (v1-35 sv-88) + ) + (set! (-> v1-35 quad) (-> a1-7 position quad)) + (set! (-> v1-35 w) 1.0) + ) + (let ((a1-10 sv-80) + (v1-36 sv-92) + ) + (set! (-> v1-36 quad) (-> a1-10 position quad)) + (set! (-> v1-36 w) 1.0) + ) + (vector-! sv-84 sv-92 sv-88) + (add-debug-vector #t (bucket-id debug2) sv-88 sv-84 (meters 0.00023193359) *color-light-green*) + (vector+float*! sv-84 sv-88 sv-84 0.5) + (let ((s4-1 add-debug-text-3d) + (s3-0 #t) + (s2-0 324) + ) + (format (clear *temp-string*) "~D" (-> sv-20 user-count)) + (s4-1 + s3-0 + (the-as bucket-id s2-0) + *temp-string* + sv-84 + (if (< (-> sv-20 user-count) (-> sv-20 max-user-count)) + (font-color yellow-#f3f300) + (font-color precursor-#ec3b00) + ) + (the-as vector2h #f) + ) + ) + ) + ) + (set! sv-16 (&+ sv-16 32)) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod debug-unused traffic-engine ((obj traffic-engine)) + (dotimes (v1-0 (-> *level* length)) + (let ((a0-4 (-> *level* level v1-0))) + (when (= (-> a0-4 status) 'active) + (when (and (!= (-> a0-4 bsp city-level-info) 0) (!= (-> a0-4 bsp city-level-info nav-graph) 0)) + ) + ) + ) + ) + (when #f + ) + 0 + (none) + ) + +;; definition for method 14 of type traffic-engine +(defmethod sphere-in-loaded-city-infos? traffic-engine ((obj traffic-engine) (arg0 int) (arg1 vector)) + (dotimes (s3-0 2) + (let ((v1-3 (-> obj level-data-array s3-0))) + (when (nonzero? (-> v1-3 city-info)) + (if (sphere-in-grid? (-> v1-3 city-info) arg0 (the-as int arg1)) + (return #t) + ) + ) + ) + ) + #f + ) + +;; definition for method 17 of type traffic-engine +(defmethod can-dest-be-used? traffic-engine ((obj traffic-engine) (arg0 nav-branch)) + (let ((v1-0 (-> arg0 src-node))) + (or (logtest? (-> arg0 flags) 1) + (logtest? (-> v1-0 flags) (nav-node-flag-byte blocked)) + (not (-> arg0 dest-node)) + (>= (-> arg0 user-count) (-> arg0 max-user-count)) + ) + ) + ) + +;; definition for method 66 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod update-sync-from-frame-counter traffic-engine ((obj traffic-engine)) + (with-pp + (+! (-> obj sync-clock) 1) + (set! (-> obj sync-mask-8) (the-as uint (ash 1 (logand (-> obj sync-clock) 7)))) + (set! (-> obj sync-mask-16) (the-as uint (ash 1 (logand (-> obj sync-clock) 15)))) + (set! (-> obj sync-mask-32) (the-as uint (ash 1 (logand (-> obj sync-clock) 31)))) + (let ((v1-10 (/ (-> pp clock frame-counter) 300))) + (set! (-> obj sync-array 0) (the-as uint 255)) + (let ((a1-12 (mod v1-10 20))) + (set! (-> obj sync-array 1) (the-as uint (cond + ((>= 6 a1-12) + 1 + ) + ((>= 9 a1-12) + 2 + ) + ((>= 16 a1-12) + 4 + ) + (else + 8 + ) + ) + ) + ) + ) + (let ((a1-15 (mod v1-10 30))) + (set! (-> obj sync-array 2) (the-as uint (cond + ((>= 6 a1-15) + 1 + ) + ((>= 9 a1-15) + 2 + ) + ((>= 16 a1-15) + 4 + ) + ((>= 19 a1-15) + 8 + ) + ((>= 26 a1-15) + 16 + ) + (else + 32 + ) + ) + ) + ) + ) + (let ((v1-11 (mod v1-10 40))) + (set! (-> obj sync-array 3) (the-as uint (cond + ((>= 6 v1-11) + 1 + ) + ((>= 9 v1-11) + 2 + ) + ((>= 16 v1-11) + 4 + ) + ((>= 19 v1-11) + 8 + ) + ((>= 26 v1-11) + 16 + ) + ((>= 29 v1-11) + 32 + ) + ((>= 36 v1-11) + 64 + ) + (else + 128 + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 70 of type traffic-engine +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod update-danger-from-target traffic-engine ((obj traffic-engine)) + "make people run away from jak when he is dangerous." + (local-vars (v1-20 float) (v1-32 float)) + (with-pp + (rlet ((acc :class vf) + (vf0 :class vf) + (vf1 :class vf) + (vf2 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 *target*)) + (when s5-0 + (let ((v1-1 (-> obj danger-sphere-array))) + (set! (-> v1-1 0 handle) (the-as uint (process->handle s5-0))) + (let ((a0-4 (-> s5-0 focus-status)) + (f0-0 0.0) + (f1-0 0.0) + (f3-0 1.0) + (f2-0 0.0) + ) + (cond + ((logtest? (focus-status mech dark shooting) a0-4) + (set! f0-0 245760.0) + (set! f1-0 163840.0) + (set! f2-0 1.0) + (set! f3-0 0.0) + ) + ((logtest? (focus-status gun) a0-4) + (set! f0-0 102400.0) + (set! f1-0 61440.0) + (set! f2-0 0.5) + (set! f3-0 0.5) + ) + ((logtest? (focus-status board pilot) a0-4) + (set! f0-0 40960.0) + (set! f1-0 24576.0) + (set! f2-0 0.5) + ) + ((logtest? a0-4 (focus-status dangerous)) + (set! f0-0 61440.0) + (set! f1-0 40960.0) + (set! f3-0 0.0) + (set! f2-0 0.5) + ) + (else + (set! f3-0 1.5) + ) + ) + (set! (-> v1-1 0 decay-rate) (* 0.1 f3-0)) + (when (< (-> v1-1 0 danger-level) f2-0) + (set! (-> v1-1 0 danger-level) f2-0) + (set! (-> v1-1 0 sphere r) f1-0) + (set! (-> v1-1 0 notify-radius) f0-0) + ) + ) + (let ((f0-1 (-> v1-1 0 sphere r))) + (set! (-> v1-1 0 sphere quad) (-> s5-0 control trans quad)) + (set! (-> v1-1 0 sphere r) f0-1) + ) + (set! (-> v1-1 0 velocity quad) (-> s5-0 control transv quad)) + (let ((f0-3 (- (-> v1-1 0 danger-level) (* (-> v1-1 0 decay-rate) (-> pp clock seconds-per-frame))))) + (set! (-> v1-1 0 danger-level) (fmax 0.0 f0-3)) + ) + ) + (let ((s3-0 (-> s5-0 focus-status)) + (f30-0 0.0) + (s4-0 (new 'stack-no-clear 'inline-array 'traffic-suppression-box 2)) + ) + (set! (-> s4-0 0 bbox max quad) (-> s5-0 control transv quad)) + (vector-z-quaternion! (the-as vector (-> s4-0 1)) (get-quat s5-0 3)) + (set! (-> s4-0 1 data 16) (the-as uint 3)) + (cond + ((logtest? (focus-status shooting) s3-0) + (vector-float*! (the-as vector (-> s4-0 0)) (the-as vector (-> s4-0 1)) 409600.0) + (set! f30-0 4096.0) + (set! (-> s4-0 1 data 16) (the-as uint 0)) + 0 + ) + ((and (logtest? (focus-status gun) s3-0) + (not (and (logtest? (focus-status pilot) s3-0) (let* ((v1-19 (-> s4-0 0 bbox max)) + (f0-6 40960.0) + (f0-8 (* f0-6 f0-6)) + ) + (.lvf vf1 (&-> v1-19 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-20 vf1) + (< f0-8 v1-20) + ) + ) + ) + ) + (vector-float*! (the-as vector (-> s4-0 0)) (the-as vector (-> s4-0 1)) 163840.0) + (set! f30-0 8192.0) + (set! (-> s4-0 1 data 16) (the-as uint 1)) + ) + ((logtest? (focus-status dangerous board pilot) s3-0) + (vector-float*! (the-as vector (-> s4-0 0)) (-> s4-0 0 bbox max) 2.0) + (let* ((v1-31 (-> s4-0 0)) + (f0-11 20480.0) + (f0-13 (* f0-11 f0-11)) + ) + (.lvf vf1 (&-> v1-31 bbox min 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-32 vf1) + (if (< f0-13 v1-32) + (set! f30-0 20480.0) + ) + ) + (set! (-> s4-0 1 data 16) (the-as uint (cond + ((logtest? (focus-status pilot) s3-0) + 3 + ) + ((logtest? (focus-status board) s3-0) + 2 + ) + ((logtest? s3-0 (focus-status dangerous)) + 4 + ) + (else + 5 + ) + ) + ) + ) + ) + ) + (when (< 0.0 f30-0) + (let ((s3-1 (new 'stack-no-clear 'array 'collide-shape 40)) + (s2-1 (new 'stack 'traffic-danger-info)) + ) + (set! (-> s2-1 sphere quad) (-> s5-0 control trans quad)) + (set! (-> s2-1 danger-type) (the-as traffic-danger-type (-> s4-0 1 data 16))) + (set! (-> s2-1 sphere r) f30-0) + (set! (-> s2-1 velocity quad) (-> s4-0 0 bbox min quad)) + (let ((gp-1 (fill-actor-list-for-line-sphere + (-> obj object-hash) + (-> s2-1 sphere) + (-> s2-1 velocity) + (-> s2-1 sphere r) + s3-1 + 40 + -1 + ) + ) + ) + (dotimes (s5-1 gp-1) + (let* ((s4-1 (-> s3-1 s5-1)) + (a0-52 (if (type? s4-1 citizen) + s4-1 + ) + ) + ) + (if a0-52 + (send-event (the-as process-tree a0-52) 'clear-path s2-1) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + ) + ) + +;; definition for method 69 of type traffic-engine +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod per-frame-danger-update traffic-engine ((obj traffic-engine)) + "see what's dangerous and make people avoid it." + (update-danger-from-target obj) + (dotimes (s5-0 (-> obj danger-sphere-count)) + (let ((s4-0 (-> obj danger-sphere-array s5-0))) + (when (< 0.0 (-> s4-0 danger-level)) + (let ((s3-0 (new 'stack-no-clear 'array 'collide-shape 40)) + (a1-0 (new 'stack-no-clear 'sphere)) + ) + (set! (-> a1-0 quad) (-> s4-0 sphere quad)) + (set! (-> a1-0 r) (-> s4-0 notify-radius)) + (let ((s2-0 (fill-actor-list-for-sphere (-> obj object-hash) a1-0 s3-0 40))) + (dotimes (s1-0 s2-0) + (let* ((s0-0 (-> s3-0 s1-0)) + (a0-6 (if (type? s0-0 citizen) + s0-0 + ) + ) + ) + (if a0-6 + (send-event + (the-as process-tree a0-6) + (if (< 0.5 (-> s4-0 danger-level)) + 'panic + 'avoid + ) + s4-0 + ) + ) + ) + ) + ) + ) + ) + ) + ) + (set! (-> obj danger-sphere-count) 1) + 0 + (none) + ) + +;; definition for method 22 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod add-danger traffic-engine ((obj traffic-engine) (arg0 traffic-danger-info)) + "Add a danger sphere and suppression box." + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((a1-1 (new 'stack-no-clear 'traffic-suppression-params))) + (let ((a0-1 (-> a1-1 bbox))) + (let ((v1-0 (-> arg0 sphere))) + (let ((a2-0 (- (-> arg0 notify-radius)))) + (.mov vf6 a2-0) + ) + (.lvf vf4 (&-> v1-0 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a0-1 min quad) vf5) + ) + (let ((a0-2 (-> a1-1 bbox max))) + (let ((v1-1 (-> arg0 sphere))) + (let ((a2-1 (-> arg0 notify-radius))) + (.mov vf6 a2-1) + ) + (.lvf vf4 (&-> v1-1 quad)) + ) + (.add.x.vf vf5 vf0 vf0 :mask #b1000) + (.add.x.vf vf5 vf4 vf6 :mask #b111) + (.svf (&-> a0-2 quad) vf5) + ) + (set! (-> a1-1 duration) (the-as uint 1500)) + (new-suppression-box obj a1-1) + ) + (let ((v1-5 (-> obj danger-sphere-count))) + (when (< v1-5 4) + (let ((a0-5 (-> obj danger-sphere-array v1-5))) + (mem-copy! (the-as pointer a0-5) (the-as pointer arg0) 54) + ) + (+! (-> obj danger-sphere-count) 1) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 60 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod kill-traffic-sphere traffic-engine ((obj traffic-engine) (arg0 sphere)) + "Kill everything in the sphere with a traffic-off-force." + (let ((gp-0 (new 'stack-no-clear 'array 'collide-shape 64))) + (countdown (s5-0 (fill-actor-list-for-sphere *actor-hash* arg0 gp-0 64)) + (let* ((s4-0 (-> gp-0 s5-0)) + (v1-3 (if (type? s4-0 collide-shape) + s4-0 + ) + ) + ) + (if v1-3 + (send-event (-> v1-3 process) 'traffic-off-force) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 68 of type traffic-engine +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod per-frame-activate-deactivate traffic-engine ((obj traffic-engine)) + "per-frame activate and deactivate processes." + (local-vars (sv-48 int) (sv-64 nav-segment)) + (set! (-> obj object-hash object-count) 0) + (let* ((v1-1 (-> obj object-hash)) + (a0-6 (/ (+ (* (* (* (-> v1-1 dimension-array 0) (-> v1-1 dimension-array 1)) (-> v1-1 dimension-array 2)) + (-> v1-1 bucket-size) + ) + 15 + ) + 16 + ) + ) + (v1-2 (the-as (pointer uinteger) (-> v1-1 bucket-array))) + ) + (while (nonzero? a0-6) + (+! a0-6 -1) + (set! (-> (the-as (pointer uint128) v1-2) 0) (the-as uint128 0)) + (set! v1-2 (&-> (the-as (pointer grid-hash-word) v1-2) 16)) + ) + ) + 0 + (new 'stack-no-clear 'vector) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (let ((a2-0 *target*)) + (when a2-0 + (cond + ((logtest? (focus-status pilot) (-> a2-0 focus-status)) + (when (nonzero? (-> a2-0 pilot)) + (let ((a2-1 (handle->process (-> a2-0 pilot vehicle)))) + (when a2-1 + (set! (-> s5-0 quad) (-> (the-as process-focusable a2-1) root-override root-prim prim-core world-sphere quad)) + (spatial-hash-method-39 (-> obj object-hash) s5-0 (the-as hash-object-info a2-1)) + ) + ) + ) + ) + (else + (set! (-> s5-0 quad) (-> a2-0 control trans quad)) + (set! (-> s5-0 w) 20480.0) + (spatial-hash-method-39 (-> obj object-hash) s5-0 (the-as hash-object-info a2-0)) + ) + ) + ) + ) + (countdown (s4-0 (-> obj citizen-tracker-array active-object-count)) + (let ((s3-0 (handle->process (-> obj citizen-tracker-array active-object-list s4-0)))) + (cond + (s3-0 + (cond + ((logtest? (-> (the-as vehicle s3-0) focus-status) (focus-status inactive)) + (deactivate-object (-> obj citizen-tracker-array) (the-as int s4-0) #f) + ) + ((begin + (let ((v1-33 (-> (the-as vehicle s3-0) root-override-2))) + (set! (-> s5-0 quad) (-> v1-33 trans quad)) + (set! (-> s5-0 w) (-> v1-33 root-prim prim-core world-sphere w)) + ) + (sphere-in-loaded-city-infos? obj (the-as int s5-0) (the-as vector 0)) + ) + (set! (-> (the-as vehicle s3-0) traffic-hash-id) + (spatial-hash-method-39 (-> obj object-hash) s5-0 (the-as hash-object-info s3-0)) + ) + ) + (else + (deactivate-object (-> obj citizen-tracker-array) (the-as int s4-0) #f) + ) + ) + ) + (else + (remove-active-process (-> obj citizen-tracker-array) (the-as int s4-0)) + ) + ) + ) + ) + (countdown (s4-1 (-> obj vehicle-tracker-array active-object-count)) + (let ((s3-1 (handle->process (-> obj vehicle-tracker-array active-object-list s4-1)))) + (cond + (s3-1 + (cond + ((logtest? (-> (the-as process-focusable s3-1) focus-status) (focus-status inactive)) + (deactivate-object (-> obj vehicle-tracker-array) (the-as int s4-1) #f) + ) + ((begin + (let ((v1-54 (-> (the-as process-focusable s3-1) root-override))) + (set! (-> s5-0 quad) (-> v1-54 trans quad)) + (set! (-> s5-0 w) (-> v1-54 root-prim prim-core world-sphere w)) + ) + (sphere-in-loaded-city-infos? obj (the-as int s5-0) (the-as vector 1)) + ) + (spatial-hash-method-39 (-> obj object-hash) s5-0 (the-as hash-object-info s3-1)) + ) + (else + (deactivate-object (-> obj vehicle-tracker-array) (the-as int s4-1) #f) + ) + ) + ) + (else + (remove-active-process (-> obj vehicle-tracker-array) (the-as int s4-1)) + ) + ) + ) + ) + ) + (dotimes (s5-1 2) + (let ((s4-2 (-> obj level-data-array s5-1))) + (when (nonzero? (-> s4-2 city-info)) + (dotimes (s3-2 (the-as int (-> s4-2 newly-active-cell-count))) + (let ((a1-22 (-> s4-2 newly-active-cell-list s3-2))) + (handle-new-vis-cell obj a1-22) + ) + ) + (dotimes (s3-3 2) + (when (> (-> obj tracker-array s3-3 inactive-object-count) 0) + (let ((s2-0 (the-as nav-segment #f))) + (let ((f30-0 10000000000000000000000000000000000000.0)) + (dotimes (s1-0 (the-as int (-> s4-2 active-cell-count))) + (let ((s0-0 (-> s4-2 active-cell-list s1-0))) + (when (and (logtest? (-> s0-0 flags) (ash 1 s3-3)) (zero? (logand (-> s0-0 flags) (vis-cell-flag suppress)))) + (set! sv-48 0) + (while (< sv-48 (-> s0-0 incoming-segment-count)) + (set! sv-64 (-> s0-0 segment-array sv-48)) + (when (= (-> sv-64 tracker-id) s3-3) + (when (not (logtest? (-> s4-2 city-info cell-array (-> sv-64 from-cell-id) flags) (ash 1 s3-3))) + (let ((f0-3 (rand-vu))) + (when (< f0-3 f30-0) + (set! f30-0 f0-3) + (set! s2-0 sv-64) + ) + ) + ) + ) + (set! sv-48 (+ sv-48 1)) + ) + ) + ) + ) + ) + (when s2-0 + (let ((a0-51 (-> s2-0 branch))) + (when (not (or (>= (-> a0-51 user-count) (-> a0-51 max-user-count)) (can-dest-be-used? obj (-> s2-0 branch)))) + (cond + ((= s3-3 1) + (if (nonzero? (-> s2-0 nav-mesh-id)) + (activate-one-vehicle obj s2-0 0.0) + ) + ) + (else + (activate-one-citizen obj s2-0 0.0) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 9 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod update-traffic traffic-engine ((obj traffic-engine)) + (update-sync-from-frame-counter obj) + (per-frame-suppressor-update obj) + (let ((s5-0 (new 'stack-no-clear 'bounding-box))) + (set-vector! + (-> s5-0 min) + 10000000000000000000000000000000000000.0 + 10000000000000000000000000000000000000.0 + 10000000000000000000000000000000000000.0 + 1.0 + ) + (set-vector! + (-> s5-0 max) + -10000000000000000000000000000000000000.0 + -10000000000000000000000000000000000000.0 + -10000000000000000000000000000000000000.0 + 1.0 + ) + (dotimes (s4-0 2) + (let ((s3-0 (-> obj level-data-array s4-0))) + (when (nonzero? (-> s3-0 city-info)) + (per-frame-cell-update s3-0) + (add-box! s5-0 (-> s3-0 active-cell-box)) + 0 + ) + ) + ) + (update-grid-for-objects-in-box (-> obj object-hash) 253 (-> s5-0 min) (-> s5-0 max)) + ) + (per-frame-activate-deactivate obj) + (set! (-> obj alert-state guard-aim-count) 0) + (per-frame-alert-update obj) + (per-frame-guard-update obj) + (per-frame-danger-update obj) + 0 + (none) + ) + +;; definition for method 21 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod callback-on-nav-segments-in-sphere traffic-engine ((obj traffic-engine) + (arg0 vector) + (arg1 int) + (arg2 traffic-find-segment-struct) + (arg3 (function traffic-find-segment-struct nav-segment none)) + ) + (dotimes (s1-0 2) + (let ((v1-3 (-> obj level-data-array s1-0))) + (if (nonzero? (-> v1-3 city-info)) + (callback-on-nav-segments-in-sphere (-> v1-3 city-info) arg0 arg1 arg2 arg3) + ) + ) + ) + 0 + (none) + ) + +;; definition of type traffic-find-segment-struct +(deftype traffic-find-segment-struct (structure) + ((best-seg nav-segment :offset-assert 0) + (best-rating float :offset-assert 4) + (dir vector :inline :offset-assert 16) + ) + :method-count-assert 9 + :size-assert #x20 + :flag-assert #x900000020 + ) + +;; definition for method 3 of type traffic-find-segment-struct +(defmethod inspect traffic-find-segment-struct ((obj traffic-find-segment-struct)) + (when (not obj) + (set! obj obj) + (goto cfg-4) + ) + (format #t "[~8x] ~A~%" obj 'traffic-find-segment-struct) + (format #t "~1Tbest-seg: #~%" (-> obj best-seg)) + (format #t "~1Tbest-rating: ~f~%" (-> obj best-rating)) + (format #t "~1Tdir: #~%" (-> obj dir)) + (label cfg-4) + obj + ) + +;; definition for method 20 of type traffic-engine +;; INFO: Used lq/sq +(defmethod find-best-segment traffic-engine ((obj traffic-engine) (arg0 vector) (arg1 vector) (arg2 int)) + (let ((gp-0 (new 'stack-no-clear 'traffic-find-segment-struct))) + (set! (-> gp-0 dir quad) (-> arg1 quad)) + (set! (-> gp-0 best-rating) -10000000000000000000000000000000000000.0) + (set! (-> gp-0 best-seg) #f) + (callback-on-nav-segments-in-sphere + obj + arg0 + arg2 + gp-0 + (lambda ((arg0 traffic-find-segment-struct) (arg1 nav-segment)) + (let ((v1-0 (new 'stack-no-clear 'vector))) + (vector-! v1-0 (-> arg1 vertex 1) (the-as vector (-> arg1 vertex))) + (let ((a2-1 v1-0) + (a3-1 v1-0) + (f0-0 (-> arg1 length)) + ) + (vector-float*! a2-1 a3-1 (/ 1.0 f0-0)) + ) + (let ((f0-4 (vector-dot v1-0 (-> arg0 dir)))) + (when (< (-> arg0 best-rating) f0-4) + (set! (-> arg0 best-rating) f0-4) + (set! (-> arg0 best-seg) arg1) + ) + ) + ) + (none) + ) + ) + (-> gp-0 best-seg) + ) + ) + +;; definition for method 28 of type traffic-engine +(defmethod maybe-increase-guard-aim-count traffic-engine ((obj traffic-engine)) + (when (< (-> obj alert-state guard-aim-count) 2) + (+! (-> obj alert-state guard-aim-count) 1) + #t + ) + ) + +;; definition for method 30 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod increase-alert-level traffic-engine ((obj traffic-engine) (arg0 int) (arg1 target)) + (with-pp + (when (and (logtest? (-> obj alert-state flags) (traffic-alert-flag target-jak)) + (logtest? (-> arg1 mask) (process-mask target)) + ) + (let ((v1-6 (min arg0 (the-as int (-> obj alert-state max-level))))) + (when #t + (set! (-> obj alert-state start-time) (-> pp clock frame-counter)) + (logclear! (-> obj alert-state flags) (traffic-alert-flag alert-ending)) + ) + (set! (-> obj alert-state level) (the-as uint (max (the-as int (-> obj alert-state level)) v1-6))) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 31 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod decrease-alert-level traffic-engine ((obj traffic-engine) (arg0 int)) + (if (logtest? (-> obj alert-state flags) (traffic-alert-flag target-jak)) + (set! (-> obj alert-state level) (the-as uint (min (the-as int (-> obj alert-state level)) arg0))) + ) + 0 + (none) + ) + +;; definition for method 32 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod set-alert-level traffic-engine ((obj traffic-engine) (arg0 int)) + (with-pp + (set! (-> obj alert-state level) (the-as uint arg0)) + (set! (-> obj alert-state start-time) (-> pp clock frame-counter)) + (logclear! (-> obj alert-state flags) (traffic-alert-flag alert-ending)) + 0 + (none) + ) + ) + +;; definition for method 33 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod set-max-alert-level traffic-engine ((obj traffic-engine) (arg0 int)) + (set! (-> obj alert-state max-level) (the-as uint arg0)) + (set! (-> obj alert-state level) (the-as uint (min (the-as int (-> obj alert-state level)) arg0))) + 0 + (none) + ) + +;; definition for method 35 of type traffic-engine +;; WARN: Return type mismatch uint vs int. +(defmethod get-alert-level traffic-engine ((obj traffic-engine)) + (the-as int (-> obj alert-state level)) + ) + +;; definition for method 36 of type traffic-engine +(defmethod get-target traffic-engine ((obj traffic-engine)) + "@returns [[*target*]]" + *target* + ) + +;; definition for function traffic-los-clear? +;; INFO: Used lq/sq +(defun traffic-los-clear? ((arg0 vector) (arg1 vector)) + (let ((v1-0 (new 'stack-no-clear 'collide-query))) + (set! (-> v1-0 start-pos quad) (-> arg0 quad)) + (vector-! (-> v1-0 move-dist) arg1 arg0) + (let ((a0-1 v1-0)) + (set! (-> a0-1 radius) 2048.0) + (set! (-> a0-1 collide-with) (collide-spec backgnd)) + (set! (-> a0-1 ignore-process0) #f) + (set! (-> a0-1 ignore-process1) #f) + (set! (-> a0-1 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1)) + (set! (-> a0-1 action-mask) (collide-action solid)) + ) + (< (fill-and-probe-using-line-sphere *collide-cache* v1-0) 0.0) + ) + ) + +;; definition for symbol *guard-target-spots*, type (array vector) +(define *guard-target-spots* (new 'static 'boxed-array :type vector + (new 'static 'vector :x 20480.0 :w 1.0) + (new 'static 'vector :x 14481.408 :z -14481.408 :w 1.0) + (new 'static 'vector :z -20480.0 :w 1.0) + (new 'static 'vector :x -14481.408 :z -14481.408 :w 1.0) + (new 'static 'vector :x -20480.0 :w 1.0) + (new 'static 'vector :x -14481.408 :z 14481.408 :w 1.0) + (new 'static 'vector :z 20480.0 :w 1.0) + (new 'static 'vector :x 14481.408 :z 14481.408 :w 1.0) + (new 'static 'vector :x 28672.0 :w 1.0) + (new 'static 'vector :x 24831.182 :z -14335.181 :w 1.0) + (new 'static 'vector :x 14336.409 :z -24829.543 :w 1.0) + (new 'static 'vector :z -28672.0 :w 1.0) + (new 'static 'vector :x -14333.952 :z -24831.182 :w 1.0) + (new 'static 'vector :x -24829.951 :z -14336.409 :w 1.0) + (new 'static 'vector :x -28672.0 :w 1.0) + (new 'static 'vector :x -24830.771 :z 14333.952 :w 1.0) + (new 'static 'vector :x -14337.229 :z 24829.951 :w 1.0) + (new 'static 'vector :z 28672.0 :w 1.0) + (new 'static 'vector :x 14335.181 :z 24830.771 :w 1.0) + (new 'static 'vector :x 24829.543 :z 14337.229 :w 1.0) + ) + ) + +;; definition for symbol *guard-id-spots*, type (array int32) +(define *guard-id-spots* (new 'static 'boxed-array :type int32 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + ) + ) + +;; definition for symbol *guard-status-spots*, type (array int32) +(define *guard-status-spots* (new 'static 'boxed-array :type int32 :length 0 :allocated-length 32)) + +;; definition for function update-guard-status-spots +(defun update-guard-status-spots ((arg0 vector)) + (local-vars (v0-1 symbol)) + (let ((s5-0 (find-nearest-nav-mesh arg0 (the-as float #x7f800000))) + (v1-0 (new 'stack-no-clear 'vector)) + ) + (new 'stack-no-clear 'vector) + (let ((s4-0 (new 'stack-no-clear 'nav-find-poly-parms))) + (if (or (not s5-0) (zero? s5-0)) + (return #f) + ) + (when s5-0 + (vector-! v1-0 arg0 (-> s5-0 bounds)) + (set! (-> s4-0 y-threshold) 40960.0) + (set! (-> s4-0 ignore) (the-as uint 2)) + (dotimes (s3-0 8) + (vector+! (-> s4-0 point) arg0 (-> *guard-target-spots* s3-0)) + (vector-! (-> s4-0 point) (-> s4-0 point) (-> s5-0 bounds)) + (cond + ((find-poly-containing-point-local s5-0 s4-0) + (vector+! (-> s4-0 point) (-> s4-0 point) (-> s5-0 bounds)) + (set! (-> *guard-status-spots* s3-0) 1) + ) + (else + (set! (-> *guard-status-spots* s3-0) 0) + 0 + ) + ) + ) + ) + ) + ) + (return #t) + v0-1 + ) + +;; definition for function generate-target-spots +;; WARN: Return type mismatch object vs none. +(defun generate-target-spots () + "Code-gen function to define [[*guard-target-spots*]] using [[*x-vector*]]" + (format #t "(define *guard-target-spots* (new 'static 'array 'vector 0~%") + (dotimes (gp-0 8) + (let ((s5-0 (new 'stack-no-clear 'vector))) + (vector-rotate-around-y! s5-0 *x-vector* (* 182.04445 (* 45.0 (the float gp-0)))) + (vector-float*! s5-0 s5-0 20480.0) + (format + #t + " (new 'static 'vector :x (meters ~M) :y (meters ~M) :z (meters ~M) :w 1.0)~%" + (-> s5-0 x) + (-> s5-0 y) + (-> s5-0 z) + ) + ) + ) + (dotimes (gp-1 12) + (let ((s5-1 (new 'stack-no-clear 'vector))) + (vector-rotate-around-y! s5-1 *x-vector* (* 182.04445 (* 30.0 (the float gp-1)))) + (vector-float*! s5-1 s5-1 28672.0) + (format + #t + " (new 'static 'vector :x (meters ~M) :y (meters ~M) :z (meters ~M) :w 1.0)~%" + (-> s5-1 x) + (-> s5-1 y) + (-> s5-1 z) + ) + ) + ) + (format #t " )~%") + (format #t " )~%") + (none) + ) + +;; definition for method 50 of type traffic-engine +(defmethod find-closest-to-with-collide-lists traffic-engine ((obj traffic-engine) (arg0 process-drawable) (arg1 collide-spec)) + "Iterate through collide lists, find the closest thing to the given process." + (let ((gp-0 (the-as process-focusable #f))) + (let ((f30-0 (the-as float #x7f800000))) + (when (logtest? arg1 (collide-spec player-list)) + (let ((v1-4 (-> *collide-player-list* alive-list next0))) + *collide-player-list* + (let ((s3-0 (-> v1-4 next0))) + (while (!= v1-4 (-> *collide-player-list* alive-list-end)) + (let ((v1-5 (the-as collide-shape (-> (the-as connection v1-4) param1)))) + (when (logtest? arg1 (-> v1-5 root-prim prim-core collide-as)) + (let* ((s1-0 (-> v1-5 process)) + (s2-0 (if (type? s1-0 process-focusable) + (the-as process-focusable s1-0) + ) + ) + ) + (when (and s2-0 (not (logtest? (-> s2-0 focus-status) (focus-status disable dead inactive))) (!= arg0 s2-0)) + (let ((f0-0 (vector-vector-xz-distance (-> arg0 root trans) (-> s2-0 root-override trans)))) + (when (or (not gp-0) (< f0-0 f30-0)) + (set! gp-0 s2-0) + (set! f30-0 f0-0) + ) + ) + ) + ) + ) + ) + (set! v1-4 s3-0) + *collide-player-list* + (set! s3-0 (-> s3-0 next0)) + ) + ) + ) + ) + (when (logtest? arg1 (collide-spec hit-by-player-list hit-by-others-list)) + (when (logtest? arg1 (collide-spec hit-by-player-list)) + (let ((v1-22 (-> *collide-hit-by-player-list* alive-list next0))) + *collide-hit-by-player-list* + (let ((s3-1 (-> v1-22 next0))) + (while (!= v1-22 (-> *collide-hit-by-player-list* alive-list-end)) + (let ((v1-23 (the-as collide-shape (-> (the-as connection v1-22) param1)))) + (when (logtest? arg1 (-> v1-23 root-prim prim-core collide-as)) + (let* ((s1-1 (-> v1-23 process)) + (s2-1 (if (type? s1-1 process-focusable) + (the-as process-focusable s1-1) + ) + ) + ) + (when (and s2-1 (not (logtest? (-> s2-1 focus-status) (focus-status disable dead inactive))) (!= arg0 s2-1)) + (let ((f0-1 (vector-vector-xz-distance (-> arg0 root trans) (-> s2-1 root-override trans)))) + (when (or (not gp-0) (< f0-1 f30-0)) + (set! gp-0 s2-1) + (set! f30-0 f0-1) + ) + ) + ) + ) + ) + ) + (set! v1-22 s3-1) + *collide-hit-by-player-list* + (set! s3-1 (-> s3-1 next0)) + ) + ) + ) + ) + (when (logtest? arg1 (collide-spec hit-by-others-list)) + (let ((v1-38 (-> *collide-hit-by-others-list* alive-list next0))) + *collide-hit-by-others-list* + (let ((s3-2 (-> v1-38 next0))) + (while (!= v1-38 (-> *collide-hit-by-others-list* alive-list-end)) + (let ((v1-39 (the-as collide-shape (-> (the-as connection v1-38) param1)))) + (when (logtest? arg1 (-> v1-39 root-prim prim-core collide-as)) + (let* ((s1-2 (-> v1-39 process)) + (s2-2 (if (type? s1-2 process-focusable) + (the-as process-focusable s1-2) + ) + ) + ) + (when (and s2-2 (not (logtest? (-> s2-2 focus-status) (focus-status disable dead inactive))) (!= arg0 s2-2)) + (let ((f0-2 (vector-vector-xz-distance (-> arg0 root trans) (-> s2-2 root-override trans)))) + (when (or (not gp-0) (< f0-2 f30-0)) + (set! gp-0 s2-2) + (set! f30-0 f0-2) + ) + ) + ) + ) + ) + ) + (set! v1-38 s3-2) + *collide-hit-by-others-list* + (set! s3-2 (-> s3-2 next0)) + ) + ) + ) + ) + ) + ) + gp-0 + ) + ) + +;; definition for method 49 of type traffic-engine +;; INFO: Used lq/sq +;; WARN: Stack slot offset 216 signed mismatch +;; WARN: Stack slot offset 216 signed mismatch +;; WARN: Stack slot offset 216 signed mismatch +;; WARN: Stack slot offset 216 signed mismatch +;; WARN: Stack slot offset 216 signed mismatch +;; WARN: Stack slot offset 216 signed mismatch +;; WARN: Stack slot offset 216 signed mismatch +;; WARN: Stack slot offset 216 signed mismatch +;; WARN: Stack slot offset 216 signed mismatch +(defmethod traffic-engine-method-49 traffic-engine ((obj traffic-engine) (arg0 object) (arg1 int) (arg2 traffic-target-status)) + (local-vars (sv-192 (array crimson-guard)) (sv-196 (array float)) (sv-200 int) (sv-208 int) (sv-216 number)) + (with-pp + (logclear! (-> arg2 flags) (traffic-target-flag visible-now updated)) + (cond + ((= (-> obj sync-mask-16) (ash 1 (logand arg1 15))) + (logior! (-> arg2 flags) (traffic-target-flag updated)) + (let ((s3-0 (handle->process (-> arg2 handle))) + (s5-0 (new 'stack-no-clear 'vector)) + ) + (when s3-0 + (set! (-> s5-0 quad) (-> (get-trans (the-as process-focusable s3-0) 3) quad)) + (cond + ((= (-> (the-as process-focusable s3-0) type) target) + (let ((s1-1 (-> obj alert-state target-status-array))) + (logclear! (-> s1-1 0 flags) (traffic-target-flag visible-now updated)) + (logior! (-> s1-1 0 flags) (traffic-target-flag updated)) + (cond + ((or (logtest? (-> s1-1 0 flags) (traffic-target-flag force-visible)) + (traffic-los-clear? (the-as vector arg0) s5-0) + ) + (logior! (-> s1-1 0 flags) (traffic-target-flag visible-now visible-recently visible-ever)) + (set! (-> s1-1 0 last-seen-time) (-> pp clock frame-counter)) + (set! (-> s1-1 0 position quad) (-> s5-0 quad)) + (set! (-> s1-1 0 velocity quad) (-> (get-transv (the-as process-focusable s3-0)) quad)) + ) + (else + (if (>= (- (-> pp clock frame-counter) (-> s1-1 0 last-seen-time)) (seconds 2)) + (logclear! (-> s1-1 0 flags) (traffic-target-flag visible-recently)) + ) + ) + ) + (mem-copy! (the-as pointer arg2) (the-as pointer s1-1) 80) + ) + 0 + ) + (else + (logior! (-> arg2 flags) (traffic-target-flag visible-now visible-recently visible-ever)) + (set! (-> arg2 last-seen-time) (-> pp clock frame-counter)) + (set! (-> arg2 position quad) (-> s5-0 quad)) + (set! (-> arg2 velocity quad) (-> (get-transv (the-as process-focusable s3-0)) quad)) + ) + ) + (set! (-> s5-0 quad) (-> arg2 position quad)) + (when (not (update-guard-status-spots s5-0)) + ) + (when (update-guard-status-spots s5-0) + (set! sv-192 (the-as (array crimson-guard) (new 'stack 'array crimson-guard 16))) + (set! sv-196 (the-as (array float) (new 'stack 'array float 16))) + (set! sv-200 0) + (dotimes (s3-1 (the-as int (-> obj vehicle-tracker-array active-object-count))) + (case (-> obj vehicle-tracker-array active-object-type-list s3-1) + (((traffic-type crimson-guard-1)) + (let ((s2-3 (handle->process (-> obj vehicle-tracker-array active-object-list s3-1)))) + (when (and s2-3 + (not (logtest? (-> (the-as process-focusable s2-3) focus-status) (focus-status dead inactive))) + (= (-> (the-as crimson-guard s2-3) traffic-target-status handle) (-> arg2 handle)) + ) + (set! (-> sv-192 sv-200) (the-as crimson-guard s2-3)) + (set! (-> sv-196 sv-200) (vector-vector-distance (-> (the-as crimson-guard s2-3) root-override2 trans) s5-0)) + (set! sv-200 (+ sv-200 1)) + (set! (-> (the-as crimson-guard s2-3) move-index) -1) + ) + ) + ) + ) + ) + (let ((a0-35 #t)) + (while a0-35 + (set! a0-35 #f) + (dotimes (v1-77 (+ sv-200 -1)) + (when (< (-> sv-196 (+ v1-77 1)) (-> sv-196 v1-77)) + (let ((a0-38 (-> sv-192 v1-77)) + (f0-2 (-> sv-196 v1-77)) + ) + (set! (-> sv-192 v1-77) (-> sv-192 (+ v1-77 1))) + (set! (-> sv-192 (+ v1-77 1)) a0-38) + (set! (-> sv-196 v1-77) (-> sv-196 (+ v1-77 1))) + (set! (-> sv-196 (+ v1-77 1)) f0-2) + ) + (set! a0-35 #t) + ) + ) + ) + ) + (dotimes (s4-1 sv-200) + (let ((s3-2 (-> (the-as (array crimson-guard) sv-192) s4-1))) + (when (= (-> s3-2 move-index) -1) + (set! sv-208 -1) + (set! sv-216 (gpr->fpr #x7f800000)) + (dotimes (s2-4 (-> *guard-target-spots* length)) + (when (= (-> *guard-status-spots* s2-4) 1) + (let* ((a0-53 (vector+! (new 'stack-no-clear 'vector) s5-0 (-> *guard-target-spots* s2-4))) + (f0-4 (vector-vector-distance a0-53 (-> s3-2 root-override2 trans))) + ) + (when (or (= sv-208 -1) (< f0-4 (the-as float (gpr->fpr sv-216)))) + (set! sv-208 s2-4) + (set! sv-216 f0-4) + ) + ) + ) + ) + (cond + ((!= sv-208 -1) + (set! (-> *guard-status-spots* sv-208) 0) + (vector+! (-> s3-2 move-position) s5-0 (-> *guard-target-spots* sv-208)) + ) + (else + (set! (-> s3-2 move-position quad) (-> s5-0 quad)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (else + (let ((s5-1 (handle->process (-> arg2 handle))) + (s3-3 (new 'stack-no-clear 'vector)) + ) + (when s5-1 + (set! (-> s3-3 quad) (-> (get-trans (the-as process-focusable s5-1) 3) quad)) + (cond + ((= (-> s5-1 type) target) + (mem-copy! (the-as pointer arg2) (the-as pointer (-> obj alert-state target-status-array)) 80) + ) + (else + ) + ) + ) + ) + (logclear! (-> arg2 flags) (traffic-target-flag updated)) + ) + ) + arg2 + ) + ) + +;; definition for method 34 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod set-alert-duration traffic-engine ((obj traffic-engine) (arg0 int)) + (set! (-> obj alert-state duration) (the-as uint arg0)) + 0 + (none) + ) + +;; definition for method 23 of type traffic-engine +(defmethod guard-count traffic-engine ((obj traffic-engine)) + (let ((v0-0 0)) + (dotimes (v1-0 6) + (+! v0-0 (-> obj alert-state guard-type-info-array v1-0 count)) + ) + v0-0 + ) + ) + +;; definition for method 53 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod end-pursuit-by-type traffic-engine ((obj traffic-engine) (arg0 traffic-type)) + (for-all-active-processes-of-type + (-> obj tracker-array (-> obj object-type-info-array arg0 tracker-index)) + arg0 + (the-as + (function process-focusable traffic-object-type-info none) + (lambda ((arg0 process-tree)) (send-event arg0 'end-pursuit) (none)) + ) + ) + 0 + (none) + ) + +;; definition for method 24 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod set-target-level traffic-engine ((obj traffic-engine) (arg0 float)) + (set! (-> obj alert-state guard-target-level) arg0) + (dotimes (v1-0 21) + (let ((a2-2 (-> obj object-type-info-array v1-0))) + (set! (-> a2-2 target-count) (the int (* arg0 (the float (max 0 (+ (-> a2-2 want-count) -1)))))) + ) + ) + 0 + (none) + ) + +;; definition for method 25 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod set-guard-target-level traffic-engine ((obj traffic-engine) (arg0 float)) + (set! (-> obj alert-state guard-target-level) arg0) + 0 + (none) + ) + +;; definition for symbol *alert-level-settings*, type traffic-alert-state-settings +(define *alert-level-settings* (new 'static 'traffic-alert-state-settings + :ped-tazer (new 'static 'traffic-guard-type-settings + :target-count 5 + :inaccuracy 0.5 + :acquire-delay #x12c + :shot-delay #x4b + :burst-delay #x258 + :shot-count 1 + ) + :ped-rifle (new 'static 'traffic-guard-type-settings + :inaccuracy 0.5 + :acquire-delay #x12c + :shot-delay #x4b + :burst-delay #x258 + :shot-count 2 + :rand-shot-count 1 + ) + :ped-grenade (new 'static 'traffic-guard-type-settings + :inaccuracy 0.5 + :acquire-delay #x12c + :shot-delay #x4b + :burst-delay #x258 + :shot-count 1 + ) + :ped-roboguard (new 'static 'traffic-guard-type-settings + :inaccuracy 0.5 + :acquire-delay #x12c + :shot-delay #x4b + :burst-delay #x258 + :shot-count 1 + ) + :bike-turret (new 'static 'traffic-guard-type-settings + :target-count 1 + :inaccuracy 0.5 + :acquire-delay #x12c + :shot-delay #x4b + :burst-delay #x5dc + :shot-count 2 + :rand-shot-count 1 + ) + :hellcat-turret (new 'static 'traffic-guard-type-settings + :target-count 1 + :inaccuracy 0.5 + :acquire-delay #x12c + :shot-delay #x4b + :burst-delay #x5dc + :shot-count 2 + :rand-shot-count 1 + ) + ) + ) + +;; definition for method 54 of type traffic-engine +(defmethod get-traffic-guard-type-settings traffic-engine ((obj traffic-engine) (arg0 int)) + "TODO - guard-type should be an enum" + (-> obj alert-state settings guard-settings-array arg0) + ) + +;; definition for method 55 of type traffic-engine +(defmethod get-guard-type-for-traffic-obj traffic-engine ((obj traffic-engine) (arg0 int)) + "TODO - guard-type should be an enum" + (-> obj object-type-info-array arg0 guard-type) + ) + +;; definition for method 56 of type traffic-engine +(defmethod get-traffic-guard-change-to-type traffic-engine ((obj traffic-engine) (arg0 int)) + "TODO - guard-type should be an enum" + (-> obj alert-state guard-type-info-array arg0 change-to-type) + ) + +;; definition for method 67 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod per-frame-guard-update traffic-engine ((obj traffic-engine)) + (dotimes (v1-0 6) + (set! (-> obj alert-state guard-type-info-array v1-0 count) 0) + ) + (let* ((f0-0 122880.0) + (f0-2 (* f0-0 f0-0)) + (a0-3 (the-as vehicle #f)) + (v1-5 0) + ) + (let ((a1-0 0)) + (dotimes (a2-0 (the-as int (-> obj citizen-tracker-array active-object-count))) + (case (-> obj citizen-tracker-array active-object-type-list a2-0) + (((traffic-type guard-bike) (traffic-type hellcat)) + (let ((a3-6 (handle->process (-> obj citizen-tracker-array active-object-list a2-0)))) + (when (and a3-6 + (not (logtest? (-> (the-as vehicle a3-6) focus-status) (focus-status dead inactive))) + (logtest? (rigid-body-object-flag alert) (-> (the-as vehicle a3-6) flags)) + ) + (let ((t0-13 (-> (the-as vehicle a3-6) info-override guard-type))) + (+! (-> obj alert-state guard-type-info-array t0-13 count) 1) + ) + (when (and (logtest? (rigid-body-object-flag in-pursuit) (-> (the-as vehicle a3-6) flags)) + (logtest? (rigid-body-object-flag target-in-sight) (-> (the-as vehicle a3-6) flags)) + ) + (+! a1-0 1) + (when (not (logtest? (-> (the-as vehicle a3-6) draw status) (draw-control-status on-screen))) + (+! v1-5 1) + (let ((f1-0 (-> (the-as vehicle a3-6) target-distance2))) + (when (< f0-2 f1-0) + (set! f0-2 f1-0) + (set! a0-3 (the-as vehicle a3-6)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (set! (-> obj alert-state guards-in-sight-of-target) a1-0) + ) + (when (< 2 v1-5) + (if (not (logtest? (-> obj alert-state flags) (traffic-alert-flag disable-pursuit-control))) + (send-event a0-3 'end-pursuit) + ) + ) + ) + (let ((f30-0 122880.0) + (s5-0 (the-as crimson-guard #f)) + (s4-0 0) + ) + (let ((s3-0 0)) + (let ((s2-0 0)) + (dotimes (s1-0 (the-as int (-> obj vehicle-tracker-array active-object-count))) + (case (-> obj vehicle-tracker-array active-object-type-list s1-0) + (((traffic-type crimson-guard-1)) + (let ((s0-0 (handle->process (-> obj vehicle-tracker-array active-object-list s1-0)))) + (when (and s0-0 (zero? (logand (-> (the-as crimson-guard s0-0) focus-status) (focus-status dead inactive)))) + (when (and (logtest? (-> (the-as crimson-guard s0-0) flags) (citizen-flag in-pursuit)) + (logtest? (-> (the-as crimson-guard s0-0) flags) (citizen-flag target-in-sight)) + ) + (+! s3-0 1) + (when (not (logtest? (-> (the-as crimson-guard s0-0) draw status) (draw-control-status on-screen))) + (+! s4-0 1) + (let ((f0-3 (-> (the-as crimson-guard s0-0) target-self-dist))) + (when (< f30-0 f0-3) + (set! f30-0 f0-3) + (set! s5-0 (the-as crimson-guard s0-0)) + ) + (if (and (< 327680.0 f0-3) + (zero? (logand (-> obj alert-state flags) (traffic-alert-flag disable-pursuit-control))) + ) + (send-event (the-as crimson-guard s0-0) 'end-pursuit) + ) + ) + ) + ) + (let ((v1-42 (-> s0-0 stack 860))) + (when (< v1-42 (the-as uint 6)) + (+! s2-0 1) + (+! (-> obj alert-state guard-type-info-array v1-42 count) 1) + ) + ) + ) + ) + ) + ) + ) + ) + (+! (-> obj alert-state guards-in-sight-of-target) s3-0) + ) + (when (< 2 s4-0) + (if (not (logtest? (-> obj alert-state flags) (traffic-alert-flag disable-pursuit-control))) + (send-event s5-0 'end-pursuit) + ) + ) + ) + (let ((v1-58 -1) + (a0-25 -1) + ) + (let ((a1-6 0) + (a2-4 9) + ) + (dotimes (a3-9 6) + (when (= (-> obj alert-state guard-type-info-array a3-9 object-type) (traffic-type crimson-guard-1)) + (let ((t1-15 (-> obj alert-state guard-type-info-array a3-9))) + (set! (-> t1-15 change-to-type) (the-as uint a3-9)) + (let ((t0-33 (- (-> t1-15 target-count) (-> t1-15 count)))) + (when (< a1-6 t0-33) + (set! v1-58 a3-9) + (set! a1-6 t0-33) + ) + (when (and (< t0-33 a2-4) (> (-> t1-15 count) 0)) + (set! a0-25 a3-9) + (set! a2-4 t0-33) + ) + ) + ) + ) + ) + ) + (when (and (!= v1-58 -1) (!= a0-25 -1)) + (set! (-> obj alert-state guard-type-info-array a0-25 change-to-type) (the-as uint v1-58)) + (set! (-> obj object-type-info-array 6 guard-type) (the-as uint v1-58)) + ) + ) + 0 + (none) + ) + +;; definition for method 71 of type traffic-engine +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod per-frame-alert-update traffic-engine ((obj traffic-engine)) + (with-pp + (if (and (logtest? (-> obj alert-state flags) (traffic-alert-flag target-jak)) *target*) + (set! (-> obj alert-state target-status-array 0 handle) (process->handle *target*)) + ) + (when #t + (mem-copy! + (the-as pointer (-> obj alert-state settings)) + (the-as pointer (+ (the-as uint *alert-level-settings*) (* (the-as uint 96) (-> obj alert-state level)))) + 96 + ) + (dotimes (v1-10 6) + (let ((a1-3 (-> obj alert-state settings guard-settings-array v1-10)) + (a0-10 (-> obj alert-state guard-type-info-array v1-10)) + ) + (set! (-> a1-3 inaccuracy) + (fmax 0.0 (fmin 1.0 (* (-> a1-3 inaccuracy) (-> obj alert-state guard-inaccuracy-factor)))) + ) + (when *target* + (when (logtest? (focus-status pilot) (-> *target* focus-status)) + (set! (-> a1-3 acquire-delay) (the-as uint (the int (* 0.75 (the float (-> a1-3 acquire-delay)))))) + (set! (-> a1-3 shot-delay) (the-as uint (the int (* 0.6 (the float (-> a1-3 shot-delay)))))) + (set! (-> a1-3 burst-delay) (the-as uint (the int (* 0.8 (the float (-> a1-3 burst-delay)))))) + ) + ) + (set! (-> a0-10 target-count) + (max + (min + (the int (* (the float (-> a1-3 target-count)) (-> obj alert-state guard-target-level))) + (-> a0-10 max-target-count) + ) + (-> a0-10 min-target-count) + ) + ) + ) + ) + ) + (dotimes (v1-13 21) + (let ((a1-8 (-> obj alert-state guard-type-mask-from-object-type v1-13))) + (when (nonzero? a1-8) + (let ((a2-18 0) + (a0-14 0) + ) + (while (nonzero? a1-8) + (if (logtest? a1-8 1) + (+! a0-14 (-> obj alert-state guard-type-info-array a2-18 target-count)) + ) + (+! a2-18 1) + (set! a1-8 (shr a1-8 1)) + ) + (set! (-> obj object-type-info-array v1-13 target-count) a0-14) + ) + ) + ) + ) + (let ((s5-0 #f)) + (when *traffic-alert-level-force* + (set! (-> obj alert-state level) (the-as uint 3)) + (logclear! (-> obj alert-state flags) (traffic-alert-flag alert-ending)) + (set! (-> obj alert-state start-time) (-> pp clock frame-counter)) + ) + (when (>= (-> obj alert-state level) (the-as uint 1)) + (set! s5-0 #t) + (cond + ((logtest? (-> obj alert-state flags) (traffic-alert-flag alert-ending)) + (cond + ((> (guard-count obj) 0) + (set! (-> obj alert-state start-time) (-> pp clock frame-counter)) + ) + (else + (when (>= (- (-> pp clock frame-counter) (-> obj alert-state start-time)) (seconds 3)) + (set! s5-0 #f) + (set! (-> obj alert-state level) (the-as uint 0)) + (logclear! (-> obj alert-state flags) (traffic-alert-flag alert-ending)) + ) + ) + ) + ) + (else + (let ((v1-39 (+ (- (-> obj alert-state start-time) (-> pp clock frame-counter)) + (the-as time-frame (-> obj alert-state duration)) + ) + ) + ) + (if (and *target* (-> *target* next-state) (= (-> *target* next-state name) 'target-hide)) + (set! v1-39 (- v1-39 (the-as time-frame (* (- (-> pp clock frame-counter) (-> *target* state-time)) 2)))) + ) + (if (> v1-39 0) + 0 + (logior! (-> obj alert-state flags) (traffic-alert-flag alert-ending)) + ) + ) + ) + ) + ) + (cond + (s5-0 + (when (not (logtest? (-> obj alert-state flags) (traffic-alert-flag alarm-on))) + (logior! (-> obj alert-state flags) (traffic-alert-flag alarm-on)) + (set! (-> *game-info* wanted-flash) (the-as basic #t)) + (if (= (-> *setting-control* user-current music) 'city1) + (set-setting! 'sound-mode #f 0 1) + ) + ) + (let ((s5-1 (new 'stack-no-clear 'vector))) + (set! (-> s5-1 quad) (-> (target-pos 0) quad)) + (if (or (= (-> *setting-control* user-default music-volume) 0.0) + (!= (-> *setting-control* user-current music) 'city1) + ) + (sound-play "city-alarm" :id (-> obj alert-state alarm-sound-id) :position s5-1) + ) + ) + (if #t + (send-alert-events obj) + ) + (let ((v1-67 0)) + (dotimes (a0-45 21) + (let ((a1-19 (-> obj object-type-info-array a0-45))) + (if #t + (+! v1-67 (-> a1-19 killed-count)) + ) + ) + ) + (if (and (>= v1-67 (the-as int (* (-> obj alert-state level) 8))) + (< (-> obj alert-state level) (-> obj alert-state max-level)) + ) + (set-alert-level obj (the-as int (+ (-> obj alert-state level) 1))) + ) + ) + ) + (else + (when (logtest? (-> obj alert-state flags) (traffic-alert-flag alarm-on)) + (logclear! (-> obj alert-state flags) (traffic-alert-flag alarm-on)) + (set! (-> *game-info* wanted-flash) #f) + (remove-setting! 'sound-mode) + (sound-stop (-> obj alert-state alarm-sound-id)) + (send-alert-events obj) + (let ((v1-84 (-> obj alert-state target-status-array))) + (logclear! (-> v1-84 0 flags) (traffic-target-flag visible-now visible-recently visible-ever)) + ) + (dotimes (v1-85 21) + (set! (-> obj object-type-info-array v1-85 killed-count) (the-as uint 0)) + 0 + ) + ) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 52 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod send-alert-events traffic-engine ((obj traffic-engine)) + (with-pp + (set! (-> obj alert-state notify-time) (-> pp clock frame-counter)) + (cond + ((> (-> obj alert-state level) 0) + (if (and (logtest? (-> obj alert-state flags) (traffic-alert-flag target-jak)) + (not (logtest? (-> obj alert-state flags) (traffic-alert-flag alert-ending))) + *target* + ) + (for-all-active-processes obj (lambda ((arg0 process-focusable) (arg1 traffic-object-type-info)) + (if (logtest? (-> arg1 flags) 1) + (send-event arg0 'alert-begin *target*) + ) + (none) + ) + ) + ) + ) + (else + (for-all-active-processes obj (lambda ((arg0 process-focusable) (arg1 traffic-object-type-info)) + (if (logtest? (-> arg1 flags) 1) + (send-event arg0 'alert-end) + ) + (none) + ) + ) + ) + ) + 0 + (none) + ) + ) + +;; definition for method 29 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod restore-default-settings traffic-engine ((obj traffic-engine)) + (restore-city-speeches) + (logclear! + (-> obj alert-state flags) + (traffic-alert-flag guard-multi-focus sticky-guard-settings disable-pursuit-control) + ) + (set! (-> obj inv-density-factor) 5.0) + (if (demo?) + (set! (-> obj inv-density-factor) 1.25) + ) + (let ((v1-6 (-> obj alert-state target-status-array))) + (logclear! (-> v1-6 0 flags) (traffic-target-flag force-visible)) + ) + (set-target-level obj 1.0) + (set-alert-duration obj 9000) + (set-max-alert-level obj 4) + (let ((v1-13 42)) + (dotimes (a0-7 21) + (let ((a1-6 (-> obj object-type-info-array a0-7))) + (set! (-> a1-6 flags) (the-as uint 6)) + (set! (-> a1-6 reserve-count) (the-as uint (max 1000 (min #xfde8 (* 1000 (-> a1-6 want-count)))))) + (set! (-> a1-6 killed-count) (the-as uint 0)) + (set! (-> a1-6 parking-spot-prob) + (the-as uint (if (and (zero? (-> a1-6 tracker-index)) (zero? (logand (-> a1-6 flags) 1))) + v1-13 + 0 + ) + ) + ) + ) + ) + ) + (let ((v1-16 (-> obj object-type-info-array 6))) + (logior! (-> v1-16 flags) 1) + ) + (let ((v1-17 (-> obj object-type-info-array 7))) + (logior! (-> v1-17 flags) 1) + ) + (let ((v1-18 (-> obj object-type-info-array 18))) + (logior! (-> v1-18 flags) 1) + ) + (let ((v1-19 (-> obj object-type-info-array 19))) + (logior! (-> v1-19 flags) 1) + ) + (let ((v1-20 (-> obj object-type-info-array 20))) + (logior! (-> v1-20 flags) 1) + ) + (let ((v1-21 (-> obj object-type-info-array 5))) + (set! (-> v1-21 target-count) 0) + (set! (-> v1-21 flags) (logand -7 (-> v1-21 flags))) + ) + (let ((v1-22 (-> obj object-type-info-array 3))) + (set! (-> v1-22 target-count) 0) + (set! (-> v1-22 flags) (logand -5 (-> v1-22 flags))) + ) + (let ((v1-23 (-> obj object-type-info-array 4))) + (set! (-> v1-23 target-count) 0) + (set! (-> v1-23 flags) (logand -5 (-> v1-23 flags))) + ) + (let ((v1-24 (-> obj object-type-info-array 17))) + (set! (-> v1-24 target-count) 0) + (set! (-> v1-24 flags) (logand -7 (-> v1-24 flags))) + ) + (dotimes (v1-25 6) + (let ((a0-28 (-> obj alert-state guard-type-info-array v1-25))) + (set! (-> a0-28 min-target-count) 0) + (set! (-> a0-28 max-target-count) 127) + ) + ) + 0 + (none) + ) + +;; definition for method 26 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod deactivate-all traffic-engine ((obj traffic-engine)) + (deactivate-all (-> obj citizen-tracker-array) #t) + (deactivate-all (-> obj vehicle-tracker-array) #t) + 0 + (none) + ) + +;; definition for method 27 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod deactivate-by-type traffic-engine ((obj traffic-engine) (arg0 traffic-type)) + (let ((a2-0 (-> obj object-type-info-array arg0))) + (deactivate-all-of-type (-> obj tracker-array (-> a2-0 tracker-index)) arg0 #t) + ) + 0 + (none) + ) + +;; definition for method 19 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod deactivate-all-from-level traffic-engine ((obj traffic-engine) (arg0 symbol)) + (local-vars (v1-6 nav-branch)) + (countdown (s4-0 (-> obj citizen-tracker-array active-object-count)) + (let ((v1-3 (handle->process (-> obj citizen-tracker-array active-object-list s4-0)))) + (when v1-3 + (cond + ((logtest? (-> (the-as process-focusable v1-3) focus-status) (focus-status inactive)) + (deactivate-object (-> obj citizen-tracker-array) (the-as int s4-0) #f) + ) + ((begin (set! v1-6 (-> (the-as vehicle v1-3) controller branch)) (and v1-6 (nonzero? v1-6))) + (let ((v1-7 (-> v1-6 dest-node))) + (cond + (v1-7 + (if (= arg0 (-> v1-7 level)) + (deactivate-object (-> obj citizen-tracker-array) (the-as int s4-0) #t) + ) + ) + (else + 0 + ) + ) + ) + ) + (else + 0 + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 58 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod set-object-auto-activate traffic-engine ((obj traffic-engine) (arg0 int) (arg1 object)) + (let ((v1-2 (-> obj object-type-info-array arg0))) + (if arg1 + (logior! (-> v1-2 flags) 4) + (set! (-> v1-2 flags) (logand -5 (-> v1-2 flags))) + ) + ) + 0 + (none) + ) + +;; definition for method 37 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod set-object-target-level traffic-engine ((obj traffic-engine) (arg0 int) (arg1 float)) + (let ((v1-2 (-> obj object-type-info-array arg0))) + (set! (-> v1-2 target-count) (the int (* arg1 (the float (max 0 (+ (-> v1-2 want-count) -1)))))) + ) + 0 + (none) + ) + +;; definition for method 38 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod set-object-target-count traffic-engine ((obj traffic-engine) (arg0 int) (arg1 int)) + (set! (-> obj object-type-info-array arg0 target-count) arg1) + 0 + (none) + ) + +;; definition for method 57 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod set-guard-target-count-range traffic-engine ((obj traffic-engine) (arg0 int) (arg1 int) (arg2 int)) + (let ((v1-2 (-> obj alert-state guard-type-info-array arg0))) + (set! (-> v1-2 min-target-count) (max 0 (min 127 arg1))) + (set! (-> v1-2 max-target-count) (max 0 (min 127 arg2))) + ) + 0 + (none) + ) + +;; definition for method 39 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod set-object-reserve-count traffic-engine ((obj traffic-engine) (arg0 int) (arg1 uint)) + (set! (-> obj object-type-info-array arg0 reserve-count) arg1) + 0 + (none) + ) + +;; definition for method 40 of type traffic-engine +;; WARN: Return type mismatch uint vs int. +(defmethod get-object-reserve-count traffic-engine ((obj traffic-engine) (arg0 int)) + (the-as int (-> obj object-type-info-array arg0 reserve-count)) + ) + +;; definition for method 41 of type traffic-engine +(defmethod get-object-remaining-count traffic-engine ((obj traffic-engine) (arg0 int)) + (let ((a0-1 (-> obj object-type-info-array arg0))) + (+ (-> a0-1 active-count) (-> a0-1 reserve-count)) + ) + ) + +;; definition for method 44 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod set-parking-spot-prob traffic-engine ((obj traffic-engine) (arg0 int) (arg1 float)) + (let ((v1-2 (-> obj object-type-info-array arg0))) + (set! (-> v1-2 parking-spot-prob) (the-as uint (min 255 (the int (* 256.0 arg1))))) + ) + 0 + (none) + ) + +;; definition for method 45 of type traffic-engine +;; WARN: Return type mismatch int vs traffic-type. +(defmethod get-random-parking-spot-type traffic-engine ((obj traffic-engine)) + (let ((s5-0 11)) + (let ((s4-0 (the int (* 256.0 (rand-vu)))) + (s3-0 0) + ) + (while (< (the-as uint s5-0) (the-as uint 21)) + (let ((s2-0 (-> obj object-type-info-array s5-0))) + (when (and (logtest? (-> s2-0 flags) 8) (= (level-status *level* (the-as symbol (-> s2-0 level))) 'active)) + (+! s3-0 (-> s2-0 parking-spot-prob)) + (b! (>= (the-as uint s3-0) (the-as uint s4-0)) cfg-10) + ) + ) + (+! s5-0 1) + ) + ) + (set! s5-0 21) + (label cfg-10) + (the-as traffic-type s5-0) + ) + ) + +;; definition for method 42 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod activate-object traffic-engine ((obj traffic-engine) (arg0 traffic-object-spawn-params)) + (let ((a2-0 (-> obj object-type-info-array (-> arg0 object-type)))) + (activate-from-params (-> obj tracker-array (-> a2-0 tracker-index)) arg0) + ) + 0 + (none) + ) + +;; definition for method 43 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod activate-by-handle traffic-engine ((obj traffic-engine) (arg0 traffic-object-spawn-params)) + (let ((a2-0 (-> obj object-type-info-array (-> arg0 object-type)))) + (activate-by-handle (-> obj tracker-array (-> a2-0 tracker-index)) arg0) + ) + 0 + (none) + ) + +;; definition for method 46 of type traffic-engine +(defmethod new-suppression-box traffic-engine ((obj traffic-engine) (arg0 traffic-suppression-params)) + (add-new-supression-box (-> obj suppressor) arg0) + (none) + ) + +;; definition for method 47 of type traffic-engine +(defmethod remove-suppression-box traffic-engine ((obj traffic-engine) (arg0 traffic-suppression-params)) + (remove-box-by-id (-> obj suppressor) (the-as int arg0)) + (none) + ) + +;; definition for method 48 of type traffic-engine +(defmethod update-suppression-box traffic-engine ((obj traffic-engine) (arg0 traffic-suppression-params)) + (update-box-from-params (-> obj suppressor) arg0) + (none) + ) + +;; definition for method 72 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod per-frame-suppressor-update traffic-engine ((obj traffic-engine)) + (let ((v1-3 (- (-> *display* game-clock frame-counter) (-> *display* game-clock old-frame-counter)))) + (dotimes (a1-3 16) + (let ((a2-2 (-> obj suppressor array a1-3))) + (when (logtest? (-> a2-2 flags) (traffic-suppression-box-flags in-use)) + (let ((a3-3 (the-as int (-> a2-2 duration)))) + (cond + ((< (the-as uint a3-3) (the-as uint v1-3)) + (logclear! (-> a2-2 flags) (traffic-suppression-box-flags in-use)) + (logior! (-> obj suppressor flags) (traffic-suppression-flags needs-update)) + ) + (else + (set! (-> a2-2 duration) (the-as uint (- (the-as time-frame a3-3) v1-3))) + ) + ) + ) + ) + ) + ) + ) + (when (logtest? (-> obj suppressor flags) (traffic-suppression-flags needs-update)) + (logclear! (-> obj suppressor flags) (traffic-suppression-flags needs-update)) + (recompute-supressions obj) + ) + 0 + (none) + ) + +;; definition for method 73 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod recompute-supressions traffic-engine ((obj traffic-engine)) + (dotimes (s5-0 2) + (let ((v1-3 (-> obj level-data-array s5-0))) + (if (nonzero? (-> v1-3 city-info)) + (update-suppressions-from-traffic-engine (-> v1-3 city-info) obj) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 0 of type traffic-engine +(defmethod new traffic-engine ((allocation symbol) (type-to-make type)) + (let ((s5-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> s5-0 object-hash) ((method-of-type spatial-hash new) allocation spatial-hash #xc1c0 253)) + s5-0 + ) + ) + +;; definition for method 14 of type city-level-info +(defmethod get-first-cell-in-box city-level-info ((obj city-level-info) (arg0 vis-grid-box)) + (-> obj + cell-array + (+ (-> arg0 min x) + (* (-> arg0 min z) (-> obj grid-info dimension-array 0)) + (* (* (-> arg0 min y) (-> obj grid-info dimension-array 0)) (-> obj grid-info dimension-array 2)) + ) + ) + ) + +;; definition for method 15 of type city-level-info +(defmethod sphere-in-grid? city-level-info ((obj city-level-info) (arg0 int) (arg1 int)) + (let ((gp-0 #f)) + (let ((s3-0 (new 'stack-no-clear 'vis-grid-box)) + (s2-0 (new 'stack-no-clear 'vis-grid-box)) + ) + (lookup-box-for-sphere (-> obj grid-info) s2-0 (the-as vector arg0)) + (set! (-> s3-0 min y) (-> s2-0 min y)) + (let ((v1-6 (+ (- 1 (-> s2-0 min y)) (-> s2-0 max y)))) + (b! #t cfg-13 :delay (nop!)) + (label cfg-1) + (+! v1-6 -1) + (set! (-> s3-0 min z) (-> s2-0 min z)) + (let ((a0-7 (+ (- 1 (-> s2-0 min z)) (-> s2-0 max z)))) + (b! #t cfg-11 :delay (nop!)) + (label cfg-2) + (+! a0-7 -1) + (set! (-> s3-0 min x) (-> s2-0 min x)) + (let ((a1-7 (+ (- 1 (-> s2-0 min x)) (-> s2-0 max x)))) + (b! #t cfg-9 :delay (nop!)) + (label cfg-3) + (+! a1-7 -1) + (let ((a3-0 obj) + (t1-0 s3-0) + ) + (b! + (not (logtest? (-> a3-0 + cell-array + (+ (-> t1-0 min x) + (* (-> t1-0 min z) (-> a3-0 grid-info dimension-array 0)) + (* (* (-> t1-0 min y) (-> a3-0 grid-info dimension-array 0)) (-> a3-0 grid-info dimension-array 2)) + ) + flags + ) + (ash 1 arg1) + ) + ) + cfg-8 + :delay (empty-form) + ) + ) + (set! gp-0 #t) + (b! #t cfg-15 :delay (nop!)) + (label cfg-8) + (+! (-> s3-0 min x) 1) + (label cfg-9) + (b! (nonzero? a1-7) cfg-3 :delay (nop!)) + ) + (+! (-> s3-0 min z) 1) + (label cfg-11) + (b! (nonzero? a0-7) cfg-2 :delay (nop!)) + ) + (+! (-> s3-0 min y) 1) + (label cfg-13) + (b! (nonzero? v1-6) cfg-1 :delay (nop!)) + ) + ) + (label cfg-15) + gp-0 + ) + ) + +;; definition for method 16 of type city-level-info +;; WARN: Stack slot offset 24 signed mismatch +;; WARN: Stack slot offset 28 signed mismatch +;; WARN: Stack slot offset 24 signed mismatch +;; WARN: Stack slot offset 28 signed mismatch +;; WARN: Stack slot offset 24 signed mismatch +;; WARN: Stack slot offset 24 signed mismatch +;; WARN: Stack slot offset 28 signed mismatch +;; WARN: Stack slot offset 24 signed mismatch +;; WARN: Stack slot offset 28 signed mismatch +;; WARN: Stack slot offset 24 signed mismatch +;; WARN: Return type mismatch int vs none. +(defmethod callback-on-nav-segments-in-sphere city-level-info ((obj city-level-info) + (arg0 vector) + (arg1 int) + (arg2 traffic-find-segment-struct) + (arg3 (function traffic-find-segment-struct nav-segment none)) + ) + (local-vars + (sv-16 city-level-info) + (sv-20 vector) + (sv-24 int) + (sv-28 traffic-find-segment-struct) + (sv-32 (function traffic-find-segment-struct nav-segment none)) + (sv-80 vis-grid-box) + (sv-84 vis-grid-box) + ) + (set! sv-16 obj) + (set! sv-20 arg0) + (set! sv-24 arg1) + (set! sv-28 arg2) + (set! sv-32 arg3) + (set! sv-80 (new 'stack-no-clear 'vis-grid-box)) + (set! sv-84 (new 'stack-no-clear 'vis-grid-box)) + (lookup-box-for-sphere (-> sv-16 grid-info) sv-80 sv-20) + (set! (-> sv-84 min y) (-> sv-80 min y)) + (countdown (gp-0 (+ (- 1 (-> sv-80 min y)) (-> sv-80 max y))) + (set! (-> sv-84 min z) (-> sv-80 min z)) + (countdown (s5-0 (+ (- 1 (-> sv-80 min z)) (-> sv-80 max z))) + (set! (-> sv-84 min x) (-> sv-80 min x)) + (countdown (s4-0 (+ (- 1 (-> sv-80 min x)) (-> sv-80 max x))) + (let* ((a0-17 sv-16) + (a2-2 sv-84) + (v1-18 + (-> a0-17 + cell-array + (+ (-> a2-2 min x) + (* (-> a2-2 min z) (-> a0-17 grid-info dimension-array 0)) + (* (* (-> a2-2 min y) (-> a0-17 grid-info dimension-array 0)) (-> a0-17 grid-info dimension-array 2)) + ) + ) + ) + (s3-0 (-> v1-18 segment-array 0)) + ) + (countdown (s2-0 (-> v1-18 segment-count)) + (if (and (= (-> s3-0 tracker-id) sv-24) + (line-sphere-intersection? sv-20 (the-as vector (-> s3-0 vertex)) (-> s3-0 vertex 1)) + ) + (sv-32 sv-28 s3-0) + ) + (&+! s3-0 48) + ) + ) + (+! (-> sv-84 min x) 1) + ) + (+! (-> sv-84 min z) 1) + ) + (+! (-> sv-84 min y) 1) + ) + 0 + (none) + ) + +;; definition for method 17 of type city-level-info +;; WARN: Return type mismatch int vs none. +(defmethod update-suppressions-from-traffic-engine city-level-info ((obj city-level-info) (arg0 traffic-engine)) + (let ((v1-0 (-> obj cell-count))) + (dotimes (a0-1 (the-as int v1-0)) + (let ((a1-2 (-> obj cell-array a0-1))) + (logclear! (-> a1-2 flags) (vis-cell-flag suppress)) + ) + ) + ) + (let ((s4-0 (new 'stack-no-clear 'inline-array 'vis-grid-pos 2))) + (dotimes (s3-0 16) + (let ((s2-0 (-> arg0 suppressor array s3-0))) + (when (logtest? (-> s2-0 flags) (traffic-suppression-box-flags in-use)) + (lookup-cell-for-point (-> obj grid-info) (-> s4-0 1) (the-as vector (-> s2-0 bbox))) + (lookup-cell-for-point (-> obj grid-info) (-> s4-0 2) (-> s2-0 bbox max)) + (set! (-> s4-0 0 y) (-> s4-0 1 y)) + (countdown (v1-15 (+ (- 1 (-> s4-0 1 y)) (-> s4-0 2 y))) + (set! (-> s4-0 0 z) (-> s4-0 1 z)) + (countdown (a0-9 (+ (- 1 (-> s4-0 1 z)) (-> s4-0 2 z))) + (set! (-> s4-0 0 x) (-> s4-0 1 x)) + (countdown (a1-10 (+ (- 1 (-> s4-0 1 x)) (-> s4-0 2 x))) + (let* ((a3-1 obj) + (t1-0 (-> s4-0 0)) + (a2-8 (-> a3-1 + cell-array + (+ (-> t1-0 x) + (* (-> t1-0 z) (-> a3-1 grid-info dimension-array 0)) + (* (* (-> t1-0 y) (-> a3-1 grid-info dimension-array 0)) (-> a3-1 grid-info dimension-array 2)) + ) + ) + ) + ) + (logior! (-> a2-8 flags) (vis-cell-flag suppress)) + ) + (+! (-> s4-0 0 x) 1) + ) + (+! (-> s4-0 0 z) 1) + ) + (+! (-> s4-0 0 y) 1) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 10 of type traffic-level-data +;; WARN: Return type mismatch int vs none. +(defmethod add-active-cell traffic-level-data ((obj traffic-level-data) (arg0 vis-cell)) + (let ((v1-0 (-> obj active-cell-count))) + (when (< v1-0 (the-as uint 255)) + (set! (-> obj active-cell-list v1-0) arg0) + (+! (-> obj active-cell-count) 1) + ) + ) + 0 + (none) + ) + +;; definition for method 11 of type traffic-level-data +;; WARN: Return type mismatch int vs none. +(defmethod remove-active-cell traffic-level-data ((obj traffic-level-data) (arg0 int)) + (let ((v1-1 (+ (-> obj active-cell-count) -1))) + (when (>= v1-1 0) + (set! (-> obj active-cell-list arg0) (-> obj active-cell-list v1-1)) + (+! (-> obj active-cell-count) -1) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type traffic-level-data +;; WARN: Return type mismatch int vs none. +(defmethod add-newly-active-cell traffic-level-data ((obj traffic-level-data) (arg0 vis-cell)) + (let ((v1-0 (-> obj newly-active-cell-count))) + (when (< v1-0 (the-as uint 255)) + (set! (-> obj newly-active-cell-list v1-0) arg0) + (+! (-> obj newly-active-cell-count) 1) + ) + ) + 0 + (none) + ) + +;; definition for method 13 of type traffic-level-data +;; WARN: Return type mismatch int vs none. +(defmethod per-frame-cell-update traffic-level-data ((obj traffic-level-data)) + (set! (-> obj newly-active-cell-count) (the-as uint 0)) + (dotimes (v1-0 (the-as int (-> obj active-cell-count))) + (let ((a0-3 (-> obj active-cell-list v1-0))) + (set! (-> a0-3 prev-flags) (-> a0-3 flags)) + ) + ) + (let ((s5-0 (math-camera-pos)) + (f30-0 81920.0) + (f28-0 819200.0) + (f26-0 491520.0) + ) + (dotimes (s4-0 (the-as int (-> obj city-info cell-count))) + (let ((s3-0 (-> obj city-info cell-array s4-0))) + (let ((f24-0 (vector-vector-distance-squared (-> s3-0 sphere) s5-0)) + (f0-1 (+ (-> s3-0 sphere r) f28-0)) + ) + (cond + ((or (< (* f0-1 f0-1) f24-0) (let ((f0-5 (+ (-> s3-0 sphere r) f30-0))) + (and (< (* f0-5 f0-5) f24-0) (not (sphere-in-view-frustum? (-> s3-0 sphere)))) + ) + ) + (logclear! (-> s3-0 flags) (vis-cell-flag active-vehicle active-pedestrian)) + ) + ((let ((f0-9 (+ (-> s3-0 sphere r) f26-0))) + (< (* f0-9 f0-9) f24-0) + ) + (let ((v1-17 (logior (-> s3-0 flags) (vis-cell-flag active-vehicle)))) + (set! (-> s3-0 flags) (logclear v1-17 (vis-cell-flag active-pedestrian))) + ) + ) + (else + (logior! (-> s3-0 flags) (vis-cell-flag active-vehicle active-pedestrian)) + ) + ) + ) + (if (< (the-as uint (logand (-> s3-0 prev-flags) (vis-cell-flag active-vehicle active-pedestrian))) + (the-as uint (logand (-> s3-0 flags) (vis-cell-flag active-vehicle active-pedestrian))) + ) + (add-newly-active-cell obj s3-0) + ) + ) + ) + ) + (countdown (s5-1 (-> obj active-cell-count)) + (let ((v1-32 (-> obj active-cell-list s5-1))) + (when (not (logtest? (-> v1-32 flags) (vis-cell-flag active-vehicle active-pedestrian))) + (logclear! (-> v1-32 prev-flags) (vis-cell-flag active-vehicle active-pedestrian)) + (remove-active-cell obj (the-as int s5-1)) + ) + ) + ) + (dotimes (s5-2 (the-as int (-> obj newly-active-cell-count))) + (let ((a1-5 (-> obj newly-active-cell-list s5-2))) + (add-active-cell obj a1-5) + ) + ) + (let ((v1-43 (-> obj active-cell-box))) + (set-vector! + (-> v1-43 min) + 10000000000000000000000000000000000000.0 + 10000000000000000000000000000000000000.0 + 10000000000000000000000000000000000000.0 + 1.0 + ) + (set-vector! + (-> v1-43 max) + -10000000000000000000000000000000000000.0 + -10000000000000000000000000000000000000.0 + -10000000000000000000000000000000000000.0 + 1.0 + ) + (countdown (a0-23 (-> obj active-cell-count)) + (let ((a1-16 (-> obj active-cell-list a0-23))) + (set! (-> v1-43 min x) (fmin (-> v1-43 min x) (- (-> a1-16 sphere x) (-> a1-16 sphere r)))) + (set! (-> v1-43 min y) (fmin (-> v1-43 min y) (- (-> a1-16 sphere y) (-> a1-16 sphere r)))) + (set! (-> v1-43 min z) (fmin (-> v1-43 min z) (- (-> a1-16 sphere z) (-> a1-16 sphere r)))) + (set! (-> v1-43 max x) (fmax (-> v1-43 max x) (+ (-> a1-16 sphere x) (-> a1-16 sphere r)))) + (set! (-> v1-43 max y) (fmax (-> v1-43 max y) (+ (-> a1-16 sphere y) (-> a1-16 sphere r)))) + (set! (-> v1-43 max z) (fmax (-> v1-43 max z) (+ (-> a1-16 sphere z) (-> a1-16 sphere r)))) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 13 of type city-level-info +(defmethod lookup-cell-by-position city-level-info ((obj city-level-info) (arg0 vector)) + (let ((s5-0 (new 'stack-no-clear 'vis-grid-pos))) + (lookup-cell-for-point (-> obj grid-info) s5-0 arg0) + (-> obj + cell-array + (+ (-> s5-0 x) + (* (-> s5-0 z) (-> obj grid-info dimension-array 0)) + (* (* (-> s5-0 y) (-> obj grid-info dimension-array 0)) (-> obj grid-info dimension-array 2)) + ) + ) + ) + ) + +;; definition for method 10 of type city-level-info +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod init-vis-ray city-level-info ((obj city-level-info) (arg0 vis-ray) (arg1 vector) (arg2 vector)) + (set! (-> arg0 pos quad) (-> arg1 quad)) + (set! (-> arg0 dest-pos quad) (-> arg2 quad)) + (let ((v1-2 (new 'stack-no-clear 'vector))) + (vector-! v1-2 arg2 arg1) + (set! (-> arg0 len) (vector-length v1-2)) + (let ((a0-9 (-> arg0 dir)) + (f0-1 (-> arg0 len)) + ) + (vector-float*! a0-9 v1-2 (/ 1.0 f0-1)) + ) + ) + (lookup-cell-for-point (-> obj grid-info) (-> arg0 grid-pos) arg1) + (set! (-> arg0 cell) (lookup-cell-by-position obj arg1)) + 0 + (none) + ) + +;; definition for method 11 of type city-level-info +;; INFO: Used lq/sq +;; WARN: Return type mismatch int vs none. +(defmethod city-level-info-method-11 city-level-info ((obj city-level-info) (arg0 vis-ray)) + (local-vars (a3-3 int)) + (let ((f0-0 (-> arg0 len)) + (s4-0 -1) + ) + (dotimes (v1-0 2) + (let ((a0-1 (* v1-0 2)) + (a1-1 (new 'stack-no-clear 'vector)) + ) + (set! (-> a1-1 quad) (the-as uint128 0)) + (set! (-> a1-1 data a0-1) -1.0) + (let ((f1-1 (-> obj grid-info box min data a0-1)) + (a2-6 1) + ) + (let ((a3-2 (-> arg0 dir data a0-1))) + (shift-arith-right-32 a3-3 a3-2 31) + ) + (set! (-> a1-1 w) + (+ f1-1 + (* (the float (+ (- a2-6 (logand a3-3 1)) (-> (the-as (pointer int8) (+ a0-1 (the-as int arg0))) 64))) + (-> obj grid-info cell-size data a0-1) + ) + ) + ) + ) + (when (!= (-> arg0 dir data a0-1) 0.0) + (let ((f1-6 (/ (- (-> a1-1 w) (-> arg0 pos data a0-1)) (-> arg0 dir data a0-1)))) + (when (< f1-6 f0-0) + (set! f0-0 f1-6) + (set! s4-0 a0-1) + (set! (-> arg0 plane quad) (-> a1-1 quad)) + ) + ) + ) + ) + ) + (cond + ((= s4-0 -1) + (set! (-> arg0 pos quad) (-> arg0 dest-pos quad)) + (set! (-> arg0 len) 0.0) + ) + (else + (vector+float*! (-> arg0 pos) (-> arg0 pos) (-> arg0 dir) f0-0) + (set! (-> arg0 len) (vector-vector-distance (-> arg0 pos) (-> arg0 dest-pos))) + (+! (-> arg0 grid-pos data s4-0) (if (>= (-> arg0 dir data s4-0) 0.0) + 1 + -1 + ) + ) + (let ((a1-4 (-> arg0 grid-pos))) + (set! (-> arg0 cell) + (-> obj + cell-array + (+ (-> a1-4 x) + (* (-> a1-4 z) (-> obj grid-info dimension-array 0)) + (* (* (-> a1-4 y) (-> obj grid-info dimension-array 0)) (-> obj grid-info dimension-array 2)) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 12 of type city-level-info +;; INFO: Used lq/sq +(defmethod city-level-info-method-12 city-level-info ((obj city-level-info) (arg0 vector) (arg1 nav-branch) (arg2 vector)) + (rlet ((acc :class vf) + (vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + (vf7 :class vf) + ) + (init-vf0-vector) + (let ((s2-0 (-> arg1 dest-node)) + (s3-0 #t) + (s5-0 (new 'stack-no-clear 'inline-array 'vector 7)) + ) + (let ((a1-1 s2-0) + (v1-0 (-> s5-0 2)) + ) + (set! (-> v1-0 quad) (-> a1-1 position quad)) + (set! (-> v1-0 w) 1.0) + ) + (let ((v1-1 s2-0) + (s1-0 (-> s5-0 3)) + ) + (let ((f0-2 (the float (-> v1-1 angle))) + (s0-0 (new 'stack-no-clear 'vector)) + ) + (sincos! s0-0 f0-2) + (set! (-> s1-0 x) (-> s0-0 y)) + (set! (-> s1-0 y) 0.0) + (set! (-> s1-0 z) (- (-> s0-0 x))) + ) + (set! (-> s1-0 w) 1.0) + ) + (vector-! (-> s5-0 5) (-> s5-0 2) arg0) + (set! (-> s5-0 4 quad) (-> s5-0 3 quad)) + (set! (-> s5-0 4 x) (-> s5-0 3 z)) + (set! (-> s5-0 4 z) (- (-> s5-0 3 x))) + (when (< 0.0 (vector-dot (-> s5-0 5) (-> s5-0 4))) + (set! s3-0 #f) + (vector-float*! (-> s5-0 4) (-> s5-0 4) -1.0) + ) + (let ((a1-8 (-> s5-0 6))) + (let ((v1-12 (-> s5-0 2))) + (let ((a0-9 (-> s5-0 4))) + (let* ((a2-1 s2-0) + (a2-4 (* 1024.0 (the float (-> a2-1 radius)))) + ) + (.mov vf7 a2-4) + ) + (.lvf vf5 (&-> a0-9 quad)) + ) + (.lvf vf4 (&-> v1-12 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-8 quad) vf6) + ) + (set! (-> s5-0 6 w) (* 1024.0 (the float (-> s2-0 radius)))) + (vector-! (-> s5-0 0) (-> s5-0 6) arg0) + (set! (-> s5-0 0 y) 0.0) + (let* ((v1-17 (-> s5-0 0)) + (f30-0 (sqrtf (+ (* (-> v1-17 x) (-> v1-17 x)) (* (-> v1-17 z) (-> v1-17 z))))) + (f28-0 (-> s5-0 6 w)) + ) + (vector-xz-normalize! (-> s5-0 0) 1.0) + (set! (-> s5-0 1 x) (-> s5-0 0 z)) + (set! (-> s5-0 1 y) 0.0) + (set! (-> s5-0 1 z) (- (-> s5-0 0 x))) + (if s3-0 + (vector-float*! (-> s5-0 1) (-> s5-0 1) -1.0) + ) + (let* ((f0-29 f30-0) + (f0-31 (* f0-29 f0-29)) + (f1-9 f28-0) + (f1-12 (sqrtf (fabs (- f0-31 (* f1-9 f1-9))))) + (f0-35 (/ (* f28-0 f1-12) f30-0)) + ) + (let ((f1-15 (/ (* f1-12 f1-12) f30-0))) + (set! (-> arg2 quad) (-> arg0 quad)) + (let ((a1-13 arg2)) + (let ((v1-26 arg2)) + (let ((a0-14 (-> s5-0 0))) + (let ((a2-5 f1-15)) + (.mov vf7 a2-5) + ) + (.lvf vf5 (&-> a0-14 quad)) + ) + (.lvf vf4 (&-> v1-26 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-13 quad) vf6) + ) + ) + (let ((a1-14 arg2)) + (let ((v1-27 arg2)) + (let ((a0-15 (-> s5-0 1))) + (let ((a2-6 f0-35)) + (.mov vf7 a2-6) + ) + (.lvf vf5 (&-> a0-15 quad)) + ) + (.lvf vf4 (&-> v1-27 quad)) + ) + (.add.x.vf vf6 vf0 vf0 :mask #b1000) + (.mul.x.vf acc vf5 vf7 :mask #b111) + (.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111) + (.svf (&-> a1-14 quad) vf6) + ) + ) + ) + (set! (-> arg2 y) (-> s5-0 2 y)) + ) + arg2 + ) + ) + +;; definition for method 18 of type city-level-info +;; INFO: Used lq/sq +;; WARN: Stack slot offset 48 signed mismatch +;; WARN: Stack slot offset 48 signed mismatch +;; WARN: Stack slot offset 48 signed mismatch +;; WARN: Stack slot offset 48 signed mismatch +;; WARN: Stack slot offset 48 signed mismatch +;; WARN: Stack slot offset 48 signed mismatch +;; WARN: Stack slot offset 48 signed mismatch +;; WARN: Return type mismatch int vs none. +(defmethod city-level-info-method-18 city-level-info ((obj city-level-info)) + (local-vars (sv-48 int)) + (let ((gp-0 (new 'stack-no-clear 'bounding-box)) + (s5-0 (-> obj nav-graph)) + ) + (set! sv-48 (-> s5-0 node-count)) + (dotimes (s4-0 sv-48) + (let ((s3-0 (-> s5-0 node-array s4-0))) + (set-id-and-link-branches-back s3-0 (the-as uint s4-0)) + (let ((a1-1 s3-0) + (v1-4 (-> gp-0 min)) + ) + (set! (-> v1-4 quad) (-> a1-1 position quad)) + (set! (-> v1-4 w) 1.0) + ) + (dotimes (s2-0 (-> s3-0 branch-count)) + (let ((s1-0 (-> s3-0 branch-array s2-0))) + (let ((a1-4 (-> s1-0 dest-node)) + (v1-6 (-> gp-0 max)) + ) + (set! (-> v1-6 quad) (-> a1-4 position quad)) + (set! (-> v1-6 w) 1.0) + ) + (set! (-> s1-0 max-user-count) + (the-as uint (max 1 (the int (/ (vector-vector-distance (-> gp-0 min) (-> gp-0 max)) + (if (logtest? (-> s3-0 flags) (nav-node-flag-byte pedestrian)) + 24576.0 + 49152.0 + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 9 of type city-level-info +;; INFO: Used lq/sq +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Stack slot offset 100 signed mismatch +;; WARN: Return type mismatch object vs symbol. +(defmethod city-level-info-method-9 city-level-info ((obj city-level-info)) + (local-vars + (sv-96 (inline-array nav-node)) + (sv-100 int) + (sv-104 vis-ray) + (sv-112 int) + (sv-160 nav-node) + (sv-164 vector) + (sv-168 vector) + (sv-172 vis-cell) + (sv-176 int) + (sv-184 nav-branch) + (sv-240 nav-node) + (sv-244 vector) + (sv-248 vector) + (sv-252 vector) + (sv-256 nav-segment) + (sv-260 vis-cell) + (sv-264 int) + ) + (set! (-> obj cell-count) + (the-as uint (* (* (-> obj grid-info dimension-array 0) (-> obj grid-info dimension-array 1)) + (-> obj grid-info dimension-array 2) + ) + ) + ) + (let ((s5-0 (-> obj cell-count))) + (dotimes (s4-0 (the-as int s5-0)) + (reset-segment-counts (-> obj cell-array s4-0)) + ) + (when (< 0.01 (-> obj grid-info axis-scale 0)) + (format 0 "segments not generates~%") + (return (the-as symbol #t)) + ) + (set! sv-96 (-> obj nav-graph node-array)) + (set! sv-100 (-> obj nav-graph node-count)) + (set! sv-104 (new 'stack-no-clear 'vis-ray)) + (set! sv-112 0) + (dotimes (s4-1 sv-100) + (let ((s3-0 (-> sv-96 s4-1))) + (dotimes (s2-0 (-> s3-0 branch-count)) + (let* ((a2-0 (-> s3-0 branch-array s2-0)) + (f0-1 0.0) + (v1-19 a2-0) + ) + (when (< f0-1 (* 0.0078125 (the float (-> v1-19 density)))) + (set! sv-160 (-> a2-0 dest-node)) + (set! sv-164 (new 'stack-no-clear 'vector)) + (set! sv-168 (new 'stack-no-clear 'vector)) + (set! sv-172 (the-as vis-cell #f)) + (set! sv-176 0) + (let ((a1-1 s3-0) + (v1-26 sv-168) + ) + (set! (-> v1-26 quad) (-> a1-1 position quad)) + (set! (-> v1-26 w) 1.0) + ) + (cond + ((logtest? (-> s3-0 flags) (nav-node-flag-byte pedestrian)) + (let ((a1-4 (-> a2-0 dest-node)) + (v1-29 sv-164) + ) + (set! (-> v1-29 quad) (-> a1-4 position quad)) + (set! (-> v1-29 w) 1.0) + ) + ) + (else + (city-level-info-method-12 obj sv-168 a2-0 sv-164) + ) + ) + (init-vis-ray obj sv-104 sv-168 sv-164) + (while (< 0.0 (-> sv-104 len)) + (set! sv-172 (-> sv-104 cell)) + (city-level-info-method-11 obj sv-104) + (+! (-> sv-172 segment-count) 1) + (set! sv-112 (+ sv-112 1)) + (if (> sv-176 0) + (+! (-> sv-172 incoming-segment-count) 1) + ) + (set! sv-176 (+ sv-176 1)) + ) + ) + ) + ) + ) + ) + (format 0 "~d segments were generated~%" sv-112) + (set! (-> obj segment-array) (the-as (inline-array nav-segment) (malloc 'debug (* 48 sv-112)))) + (let ((v1-59 0)) + (dotimes (a0-20 (the-as int s5-0)) + (let ((a1-14 (-> obj cell-array a0-20))) + (set! (-> a1-14 id) (the-as uint a0-20)) + (set! (-> a1-14 segment-array) (the-as (inline-array nav-segment) #f)) + (when (> (-> a1-14 segment-count) 0) + (set! (-> a1-14 segment-array) (the-as (inline-array nav-segment) (-> obj segment-array v1-59))) + (dotimes (a2-8 (-> a1-14 segment-count)) + (let ((a3-5 (-> a1-14 segment-array a2-8))) + (set! (-> a3-5 id) (the-as uint v1-59)) + (set! (-> a3-5 cell-id) (the-as uint #xffff)) + ) + (+! v1-59 1) + ) + ) + (set! (-> a1-14 flags) (the-as vis-cell-flag (-> a1-14 segment-count))) + (set! (-> a1-14 segment-count) 0) + (set! (-> a1-14 incoming-segment-count) 0) + ) + 0 + ) + (set! (-> obj segment-count) v1-59) + ) + ) + (dotimes (s5-1 sv-100) + (let ((s4-2 (-> sv-96 s5-1))) + (dotimes (s3-1 (-> s4-2 branch-count)) + (set! sv-184 (-> s4-2 branch-array s3-1)) + (let ((f0-5 0.0) + (v1-63 sv-184) + ) + (when (< f0-5 (* 0.0078125 (the float (-> v1-63 density)))) + (set! sv-240 (-> sv-184 dest-node)) + (set! sv-244 (new 'stack-no-clear 'vector)) + (set! sv-248 (new 'stack-no-clear 'vector)) + (set! sv-252 (new 'stack-no-clear 'vector)) + (set! sv-256 (the-as nav-segment #f)) + (set! sv-260 (the-as vis-cell #f)) + (set! sv-264 0) + (let ((a1-16 s4-2) + (v1-72 sv-244) + ) + (set! (-> v1-72 quad) (-> a1-16 position quad)) + (set! (-> v1-72 w) 1.0) + ) + (cond + ((logtest? (-> s4-2 flags) (nav-node-flag-byte pedestrian)) + (let ((a1-19 (-> sv-184 dest-node)) + (v1-76 sv-252) + ) + (set! (-> v1-76 quad) (-> a1-19 position quad)) + (set! (-> v1-76 w) 1.0) + ) + ) + (else + (city-level-info-method-12 obj sv-244 sv-184 sv-252) + ) + ) + (init-vis-ray obj sv-104 sv-244 sv-252) + (while (< 0.0 (-> sv-104 len)) + (set! (-> sv-248 quad) (-> sv-104 pos quad)) + (set! sv-260 (-> sv-104 cell)) + (city-level-info-method-11 obj sv-104) + (let ((a2-14 (-> sv-260 incoming-segment-count))) + (if (zero? sv-264) + (set! a2-14 + (+ (- -1 (-> sv-260 segment-count)) (-> sv-260 incoming-segment-count) (-> sv-260 alloc-segment-count)) + ) + ) + (when (or (< a2-14 0) (>= a2-14 (-> sv-260 alloc-segment-count))) + (format + 0 + "******************************************************** bad i-seg ~d ************************************************~%" + a2-14 + ) + (return (the-as symbol #f)) + ) + (let ((s2-1 (-> sv-260 segment-array a2-14))) + (set! (-> s2-1 vertex 0 quad) (-> sv-248 quad)) + (set! (-> s2-1 vertex 1 quad) (-> sv-104 pos quad)) + (set! (-> s2-1 length) (vector-vector-distance (the-as vector (-> s2-1 vertex)) (-> s2-1 vertex 1))) + (let* ((f0-9 (if (logtest? (-> s4-2 flags) (nav-node-flag-byte pedestrian)) + 24576.0 + 49152.0 + ) + ) + (f1-8 -1.0) + (f2-4 0.0001) + (v1-107 sv-184) + (f2-5 (fmax f2-4 (* 0.0078125 (the float (-> v1-107 density))))) + ) + (set! (-> s2-1 spawn-spacing) (* f0-9 (+ f1-8 (/ 1.0 f2-5)))) + ) + (set! (-> s2-1 cell-id) (-> sv-260 id)) + (set! (-> s2-1 branch) sv-184) + (set! (-> s2-1 from-cell-id) (the-as uint #xffff)) + (set! (-> s2-1 nav-mesh-id) (-> s4-2 nav-mesh-id)) + (set! (-> s2-1 tracker-id) 0) + (if (logtest? (-> s4-2 flags) (nav-node-flag-byte pedestrian)) + (set! (-> s2-1 tracker-id) 1) + ) + (if sv-256 + (set! (-> s2-1 from-cell-id) (-> (the-as nav-segment sv-256) cell-id)) + ) + (set! sv-256 s2-1) + ) + ) + 0 + (+! (-> sv-260 segment-count) 1) + (if (> sv-264 0) + (+! (-> sv-260 incoming-segment-count) 1) + ) + (set! sv-264 (+ sv-264 1)) + ) + ) + ) + ) + ) + ) + (the-as symbol 0) + ) + +;; definition for method 59 of type traffic-engine +;; WARN: Return type mismatch int vs none. +(defmethod debug-check-proc-in-tracker traffic-engine ((obj traffic-engine) (arg0 process) (arg1 int)) + (let ((v1-3 (-> obj tracker-array arg1)) + (a0-3 (process->handle arg0)) + (a3-4 0) + ) + (b! #t cfg-8 :delay (nop!)) + (label cfg-6) + (b! (= (-> v1-3 active-object-list a3-4) a0-3) cfg-10 :delay (nop!)) + (+! a3-4 1) + (label cfg-8) + (b! (< a3-4 (the-as int (-> v1-3 active-object-count))) cfg-6) + ) + (format #t "proc pid ~d (~a) not found in tracker ~d~%" (-> arg0 pid) arg0 arg1) + (label cfg-10) + 0 + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/jak2/levels/city/common/traffic-manager_REF.gc b/test/decompiler/reference/jak2/levels/city/common/traffic-manager_REF.gc index c4a4d19a09..f440b0d9de 100644 --- a/test/decompiler/reference/jak2/levels/city/common/traffic-manager_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/traffic-manager_REF.gc @@ -54,8 +54,8 @@ (let ((v1-0 (-> arg0 grid-info box))) (add-debug-box #t (bucket-id debug2) (-> v1-0 min) (-> v1-0 max) *color-yellow*) ) - (grid-info-method-12 (-> arg0 grid-info) *color-gray*) - (grid-info-method-13 (-> arg0 grid-info) arg1 *color-red*) + (debug-draw-grid (-> arg0 grid-info) *color-gray*) + (debug-draw-cell (-> arg0 grid-info) arg1 *color-red*) (let* ((v1-8 (+ (-> arg1 x) (* (-> arg1 z) (-> arg0 grid-info dimension-array 0)) (* (* (-> arg1 y) (-> arg0 grid-info dimension-array 0)) (-> arg0 grid-info dimension-array 2)) @@ -72,14 +72,14 @@ ;; definition for method 16 of type traffic-manager ;; WARN: Return type mismatch int vs none. (defmethod traffic-manager-method-16 traffic-manager ((obj traffic-manager)) - (traffic-engine-method-9 (-> obj traffic-engine)) + (update-traffic (-> obj traffic-engine)) (traffic-manager-method-18 obj) (spawn-all obj) (if *debug-segment* - (traffic-engine-method-12 (-> obj traffic-engine)) + (debug-unused (-> obj traffic-engine)) ) (if *display-traffic-height-map* - (xz-height-map-method-13 *traffic-height-map* (target-pos 0)) + (debug-draw *traffic-height-map* (target-pos 0)) ) (when *display-trail-graph* (let ((a0-7 *trail-graph*)) @@ -101,9 +101,11 @@ (when (logtest? (-> v1-2 flags) 2) (let ((a0-5 (+ (-> v1-2 active-count) (-> v1-2 inactive-count)))) (when (< (-> v1-2 want-count) a0-5) - (let ((a0-10 (handle->process - (traffic-tracker-method-15 (-> obj traffic-engine tracker-array (-> v1-2 tracker-index)) s5-0) - ) + (let ((a0-10 (handle->process (get-from-inactive-by-type + (-> obj traffic-engine tracker-array (-> v1-2 tracker-index)) + (the-as traffic-type s5-0) + ) + ) ) ) (if a0-10 @@ -128,9 +130,11 @@ (while (< (the-as uint s5-0) (the-as uint 21)) (let ((s4-0 (-> obj traffic-engine object-type-info-array s5-0))) (countdown (s3-0 (-> s4-0 inactive-count)) - (let ((a0-6 (handle->process - (traffic-tracker-method-15 (-> obj traffic-engine tracker-array (-> s4-0 tracker-index)) s5-0) - ) + (let ((a0-6 (handle->process (get-from-inactive-by-type + (-> obj traffic-engine tracker-array (-> s4-0 tracker-index)) + (the-as traffic-type s5-0) + ) + ) ) ) (if a0-6 @@ -184,7 +188,7 @@ ) (set! (-> s2-0 flags) (logand -9 (-> s2-0 flags))) (b! - (not (and (= (-> s2-0 object-type) 6) + (not (and (= (-> s2-0 object-type) (traffic-type crimson-guard-1)) (> (-> obj dark-guard-ratio) 0) (zero? (mod v1-21 (-> obj dark-guard-ratio))) ) @@ -197,7 +201,7 @@ (label cfg-25) (let ((a2-0 (traffic-object-spawn obj s2-0))) (b! (not a2-0) cfg-27 :delay (nop!)) - (add-object (-> obj traffic-engine) (the-as int s1-0) a2-0) + (add-object (-> obj traffic-engine) s1-0 a2-0) ) (+! (-> s0-0 reserve-count) -1) ) @@ -217,7 +221,7 @@ (if (>= (the-as uint v1-37) (the-as uint 21)) (set! v1-37 0) ) - (set! (-> s2-0 object-type) (the-as uint v1-37)) + (set! (-> s2-0 object-type) (the-as traffic-type v1-37)) ) ) (label cfg-36) @@ -280,60 +284,58 @@ ;; definition for function traffic-object-spawn (defun traffic-object-spawn ((arg0 process) (arg1 traffic-object-spawn-params)) (let ((v0-0 (the-as process-drawable #f))) - (let ((v1-0 (-> arg1 object-type))) - (cond - ((= v1-0 11) - (set! v0-0 (vehicle-spawn arg0 bikea arg1)) - ) - ((= v1-0 12) - (set! v0-0 (vehicle-spawn arg0 bikeb arg1)) - ) - ((= v1-0 13) - (set! v0-0 (vehicle-spawn arg0 bikec arg1)) - ) - ((= v1-0 14) - (set! v0-0 (vehicle-spawn arg0 cara arg1)) - ) - ((= v1-0 15) - (set! v0-0 (vehicle-spawn arg0 carb arg1)) - ) - ((= v1-0 16) - (set! v0-0 (vehicle-spawn arg0 carc arg1)) - ) - ((= v1-0 18) - (set! v0-0 (vehicle-spawn arg0 guard-bike arg1)) - ) - ((= v1-0 19) - (set! v0-0 (vehicle-spawn arg0 hellcat arg1)) - ) - ((zero? v1-0) - (set! v0-0 (citizen-spawn arg0 citizen-norm arg1)) - ) - ((= v1-0 1) - (set! v0-0 (citizen-spawn arg0 citizen-chick arg1)) - ) - ((= v1-0 2) - (set! v0-0 (citizen-spawn arg0 citizen-fat arg1)) - ) - ((= v1-0 3) - (set! v0-0 (citizen-spawn arg0 citizen-norm arg1)) - ) - ((= v1-0 10) - (set! v0-0 (citizen-spawn arg0 metalhead-predator arg1)) - ) - ((= v1-0 8) - (set! v0-0 (citizen-spawn arg0 metalhead-grunt arg1)) - ) - ((= v1-0 9) - (set! v0-0 (citizen-spawn arg0 metalhead-flitter arg1)) - ) - ((= v1-0 6) - (set! v0-0 (citizen-spawn arg0 crimson-guard arg1)) - ) - ((= v1-0 4) - (set! v0-0 (citizen-spawn arg0 crimson-guard arg1)) - ) - ) + (case (-> arg1 object-type) + (((traffic-type bikea)) + (set! v0-0 (vehicle-spawn arg0 bikea arg1)) + ) + (((traffic-type bikeb)) + (set! v0-0 (vehicle-spawn arg0 bikeb arg1)) + ) + (((traffic-type bikec)) + (set! v0-0 (vehicle-spawn arg0 bikec arg1)) + ) + (((traffic-type cara)) + (set! v0-0 (vehicle-spawn arg0 cara arg1)) + ) + (((traffic-type carb)) + (set! v0-0 (vehicle-spawn arg0 carb arg1)) + ) + (((traffic-type carc)) + (set! v0-0 (vehicle-spawn arg0 carc arg1)) + ) + (((traffic-type guard-bike)) + (set! v0-0 (vehicle-spawn arg0 guard-bike arg1)) + ) + (((traffic-type hellcat)) + (set! v0-0 (vehicle-spawn arg0 hellcat arg1)) + ) + (((traffic-type citizen-norm-1)) + (set! v0-0 (citizen-spawn arg0 citizen-norm arg1)) + ) + (((traffic-type citizen-chick)) + (set! v0-0 (citizen-spawn arg0 citizen-chick arg1)) + ) + (((traffic-type citizen-fat)) + (set! v0-0 (citizen-spawn arg0 citizen-fat arg1)) + ) + (((traffic-type citizen-norm-2)) + (set! v0-0 (citizen-spawn arg0 citizen-norm arg1)) + ) + (((traffic-type metalhead-predator)) + (set! v0-0 (citizen-spawn arg0 metalhead-predator arg1)) + ) + (((traffic-type metalhead-grunt)) + (set! v0-0 (citizen-spawn arg0 metalhead-grunt arg1)) + ) + (((traffic-type metalhead-flitter)) + (set! v0-0 (citizen-spawn arg0 metalhead-flitter arg1)) + ) + (((traffic-type crimson-guard-1)) + (set! v0-0 (citizen-spawn arg0 crimson-guard arg1)) + ) + (((traffic-type crimson-guard-0)) + (set! v0-0 (citizen-spawn arg0 crimson-guard arg1)) + ) ) v0-0 ) @@ -385,7 +387,7 @@ ;; WARN: Return type mismatch int vs none. (defmethod traffic-manager-method-20 traffic-manager ((obj traffic-manager)) (set! (-> obj traffic-engine) *traffic-engine*) - (traffic-engine-method-10 (-> obj traffic-engine) obj) + (reset-and-init-from-manager (-> obj traffic-engine) obj) (restore-city-speeches) 0 (none) @@ -403,7 +405,7 @@ ;; definition for method 10 of type traffic-manager (defmethod deactivate traffic-manager ((obj traffic-manager)) - (traffic-engine-method-11 (-> obj traffic-engine)) + (stop-alarm-sound (-> obj traffic-engine)) (set! *traffic-manager* #f) (remove-setting *setting-control* obj 'task-mask) (apply-settings *setting-control*) @@ -444,7 +446,7 @@ ) ) (let ((s5-1 (-> obj spawn-params))) - (set! (-> s5-1 object-type) (the-as uint 6)) + (set! (-> s5-1 object-type) (traffic-type crimson-guard-1)) (set! (-> s5-1 behavior) (the-as uint 1)) (set! (-> s5-1 id) (the-as uint 0)) (set! (-> s5-1 nav-mesh) #f) @@ -484,23 +486,23 @@ (('increase-alert-level) (when *target* (let ((a1-4 (-> arg3 param 0))) - (increase-alert-level (-> self traffic-engine) a1-4 *target*) + (increase-alert-level (-> self traffic-engine) (the-as int a1-4) *target*) ) ) ) (('decrease-alert-level) (let ((a1-5 (-> arg3 param 0))) - (decrease-alert-level (-> self traffic-engine) a1-5) + (decrease-alert-level (-> self traffic-engine) (the-as int a1-5)) ) ) (('set-alert-level) (let ((a1-6 (-> arg3 param 0))) - (set-alert-level (-> self traffic-engine) a1-6) + (set-alert-level (-> self traffic-engine) (the-as int a1-6)) ) ) (('set-max-alert-level) (let ((a1-7 (-> arg3 param 0))) - (set-max-alert-level (-> self traffic-engine) a1-7) + (set-max-alert-level (-> self traffic-engine) (the-as int a1-7)) ) ) (('get-alert-level) @@ -508,7 +510,7 @@ ) (('set-alert-duration) (let ((a1-8 (-> arg3 param 0))) - (set-alert-duration (-> self traffic-engine) a1-8) + (set-alert-duration (-> self traffic-engine) (the-as int a1-8)) ) ) (('deactivate-all) @@ -529,7 +531,7 @@ ) (('add-danger-sphere) (let ((a1-11 (-> arg3 param 0))) - (add-danger-sphere (-> self traffic-engine) (the-as traffic-danger-info a1-11)) + (add-danger (-> self traffic-engine) (the-as traffic-danger-info a1-11)) ) ) (('spawn-object) @@ -583,12 +585,12 @@ ) (('deactivate-by-type) (let ((a1-20 (-> arg3 param 0))) - (deactivate-by-type (-> self traffic-engine) (the-as int a1-20)) + (deactivate-by-type (-> self traffic-engine) (the-as traffic-type a1-20)) ) ) (('new-suppression-box) (let ((a1-21 (-> arg3 param 0))) - (new-suppression-box (-> self traffic-engine) a1-21) + (new-suppression-box (-> self traffic-engine) (the-as traffic-suppression-params a1-21)) ) ) (('update-suppression-box) @@ -625,7 +627,7 @@ (let ((a1-26 (-> arg3 param 0)) (a2-6 (-> arg3 param 1)) ) - (set-object-auto-activate (-> self traffic-engine) a1-26 a2-6) + (set-object-auto-activate (-> self traffic-engine) (the-as int a1-26) a2-6) ) ) (('set-guard-force-visible) @@ -640,7 +642,7 @@ ) (('end-pursuit-by-type) (let ((a1-28 (-> arg3 param 0))) - (end-pursuit-by-type (-> self traffic-engine) (the-as int a1-28)) + (end-pursuit-by-type (-> self traffic-engine) (the-as traffic-type a1-28)) ) ) (('level-loaded) @@ -658,7 +660,7 @@ (let ((a1-32 (-> arg3 param 0)) (a2-8 (-> arg3 param 1)) ) - (add-object (-> self traffic-engine) (the-as int a1-32) (the-as process a2-8)) + (add-object (-> self traffic-engine) (the-as traffic-type a1-32) (the-as process a2-8)) ) ) (('kill-all) diff --git a/test/decompiler/reference/jak2/levels/city/common/transport_REF.gc b/test/decompiler/reference/jak2/levels/city/common/transport_REF.gc index 77040e77d8..4e12a7f774 100644 --- a/test/decompiler/reference/jak2/levels/city/common/transport_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/transport_REF.gc @@ -83,7 +83,7 @@ (defstate idle (vehicle-turret) :virtual #t :trans (behavior () - (turret-control-method-12 (-> self turret) (the-as joint-mod-rotate-local (-> self turret-jm))) + (update-joint-mod (-> self turret) (the-as joint-mod-rotate-local (-> self turret-jm))) (vehicle-turret-method-29 self) (when (and (nonzero? (-> self target)) (handle->process (-> self target))) (let* ((s5-0 (handle->process (-> self target))) @@ -164,7 +164,7 @@ ;; WARN: Return type mismatch object vs none. (defbehavior vehicle-turret-init-by-other vehicle-turret ((arg0 turret-control-info)) (vehicle-turret-method-28 self) - (turret-control-method-15 (-> self turret) arg0) + (set-info (-> self turret) arg0) (logior! (-> self turret flags) (turret-flag targetting-laser no-rot-y-clamp)) (vehicle-turret-method-29 self) (vector-identity! (-> self root-override scale)) @@ -509,7 +509,7 @@ (with-pp (when (>= (- (-> pp clock frame-counter) (-> obj last-guard-spawn-time)) 0) (let ((s5-0 (new 'stack 'traffic-object-spawn-params))) - (set! (-> s5-0 object-type) (the-as uint 6)) + (set! (-> s5-0 object-type) (traffic-type crimson-guard-1)) (set! (-> s5-0 behavior) (the-as uint 6)) (set! (-> s5-0 id) (the-as uint 0)) (set! (-> s5-0 nav-mesh) (-> obj nav-mesh)) diff --git a/test/decompiler/reference/jak2/levels/city/common/vehicle-effects_REF.gc b/test/decompiler/reference/jak2/levels/city/common/vehicle-effects_REF.gc index 378e3b04ba..5d4e85a1b0 100644 --- a/test/decompiler/reference/jak2/levels/city/common/vehicle-effects_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/vehicle-effects_REF.gc @@ -4,7 +4,7 @@ ;; definition for method 36 of type vehicle ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-36 vehicle ((obj vehicle)) +(defmethod do-engine-sounds vehicle ((obj vehicle)) (local-vars (v1-36 float)) (with-pp (rlet ((acc :class vf) @@ -225,7 +225,7 @@ ;; definition for method 84 of type vehicle ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -(defmethod vehicle-method-84 vehicle ((obj vehicle) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) +(defmethod draw-thruster vehicle ((obj vehicle) (arg0 vector) (arg1 vector) (arg2 float) (arg3 float)) (rlet ((acc :class vf) (vf0 :class vf) (vf4 :class vf) @@ -317,7 +317,7 @@ ;; definition for method 85 of type vehicle ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -(defmethod vehicle-method-85 vehicle ((obj vehicle)) +(defmethod draw-thrusters vehicle ((obj vehicle)) (local-vars (sv-272 sparticle-launcher) (sv-276 sparticle-launcher)) (with-pp (when (= (-> obj controller traffic sync-mask-32) (ash 1 (logand (-> obj traffic-priority-id) 31))) @@ -440,7 +440,7 @@ ) (dotimes (s4-2 2) (vector-matrix*! (the-as vector (-> s5-0 0)) (-> obj info-override thruster-local-pos s4-2) (-> s5-0 1)) - (vehicle-method-84 obj (the-as vector (-> s5-0 0)) (-> s5-0 0 vector 1) f28-3 f30-2) + (draw-thruster obj (the-as vector (-> s5-0 0)) (-> s5-0 0 vector 1) f28-3 f30-2) ) ) (when (logtest? (rigid-body-object-flag ignition) (-> obj flags)) diff --git a/test/decompiler/reference/jak2/levels/city/common/vehicle-guard_REF.gc b/test/decompiler/reference/jak2/levels/city/common/vehicle-guard_REF.gc index 7ab43ba20e..8895d67606 100644 --- a/test/decompiler/reference/jak2/levels/city/common/vehicle-guard_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/vehicle-guard_REF.gc @@ -99,10 +99,10 @@ (turret-control-method-9 (_type_ vehicle vector vector) none 9) (turret-control-method-10 (_type_ vehicle) none 10) (turret-control-method-11 (_type_ object object vector) none 11) - (turret-control-method-12 (_type_ joint-mod-rotate-local) none 12) + (update-joint-mod (_type_ joint-mod-rotate-local) none 12) (turret-control-method-13 (_type_) none 13) (turret-control-method-14 (_type_) none 14) - (turret-control-method-15 (_type_ turret-control-info) none 15) + (set-info (_type_ turret-control-info) none 15) (turret-control-method-16 (_type_ float float) none 16) (turret-control-method-17 (_type_ vehicle) none 17) ) @@ -161,7 +161,7 @@ ;; definition for method 15 of type turret-control ;; WARN: Return type mismatch int vs none. -(defmethod turret-control-method-15 turret-control ((obj turret-control) (arg0 turret-control-info)) +(defmethod set-info turret-control ((obj turret-control) (arg0 turret-control-info)) (set! (-> obj info) arg0) (set! (-> obj owner-handle) (the-as handle #f)) 0 @@ -170,7 +170,7 @@ ;; definition for method 12 of type turret-control ;; WARN: Return type mismatch int vs none. -(defmethod turret-control-method-12 turret-control ((obj turret-control) (arg0 joint-mod-rotate-local)) +(defmethod update-joint-mod turret-control ((obj turret-control) (arg0 joint-mod-rotate-local)) (let ((v1-0 (new 'stack-no-clear 'vector))) (set! (-> v1-0 x) (- (-> obj aim-rot-x))) (set! (-> v1-0 y) (-> obj aim-rot-y)) @@ -967,7 +967,7 @@ (set! (-> a1-2 flags) (traffic-danger-flags tdf0)) (set! (-> a1-2 danger-type) (traffic-danger-type tdt6)) (set! (-> a1-2 handle) (the-as uint #f)) - (add-danger-sphere (-> obj controller traffic) a1-2) + (add-danger (-> obj controller traffic) a1-2) ) ) ) @@ -1139,8 +1139,8 @@ ;; definition for method 31 of type vehicle-guard ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-31 vehicle-guard ((obj vehicle-guard) (arg0 rigid-body-vehicle-constants)) - (let ((t9-0 (method-of-type vehicle rigid-body-object-method-31))) +(defmethod alloc-and-init-rigid-body-control vehicle-guard ((obj vehicle-guard) (arg0 rigid-body-vehicle-constants)) + (let ((t9-0 (method-of-type vehicle alloc-and-init-rigid-body-control))) (t9-0 obj arg0) ) (set! (-> obj mask) (logior (process-mask enemy guard) (-> obj mask))) diff --git a/test/decompiler/reference/jak2/levels/city/common/vehicle-h_REF.gc b/test/decompiler/reference/jak2/levels/city/common/vehicle-h_REF.gc index 9e197b168f..4fabd86fc7 100644 --- a/test/decompiler/reference/jak2/levels/city/common/vehicle-h_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/vehicle-h_REF.gc @@ -636,7 +636,7 @@ :size-assert #x370 :flag-assert #x9002f00370 (:methods - (rigid-body-object-method-31 (_type_ rigid-body-vehicle-constants) none :replace 31) + (alloc-and-init-rigid-body-control (_type_ rigid-body-vehicle-constants) none :replace 31) (inactive () _type_ :state 53) (waiting () _type_ :state 54) (vehicle-method-55 () _type_ :state 55) @@ -649,16 +649,16 @@ (vehicle-method-62 (_type_ float) none 62) (vehicle-method-63 (_type_ float) none 63) (vehicle-method-64 () none 64) - (vehicle-method-65 (_type_) none 65) + (start-jump (_type_) none 65) (vehicle-method-66 () none 66) - (vehicle-method-67 (_type_) none 67) - (vehicle-method-68 (_type_ vector int) none 68) - (vehicle-method-69 (_type_ int) process 69) + (get-seat-count (_type_) int 67) + (compute-seat-position (_type_ vector int) none 68) + (get-rider-in-seat (_type_ int) process 69) (vehicle-method-70 (_type_) process 70) - (vehicle-method-71 (_type_ int process-focusable) none 71) + (put-rider-in-seat (_type_ int process-focusable) none 71) (vehicle-method-72 (_type_) uint 72) - (vehicle-method-73 (_type_ vector int int) int 73) - (vehicle-method-74 (_type_ process) none 74) + (get-best-seat-for-vehicle (_type_ vector int int) int 73) + (remove-rider (_type_ process) none 74) (vehicle-method-75 (_type_) float 75) (vehicle-method-76 (_type_ int uint) none 76) (vehicle-method-77 (_type_) none 77) @@ -668,9 +668,9 @@ (vehicle-method-81 (_type_) none 81) (vehicle-method-82 (_type_) none 82) (vehicle-method-83 (_type_) none 83) - (vehicle-method-84 (_type_ vector vector float float) none 84) - (vehicle-method-85 (_type_) none 85) - (vehicle-method-86 () none 86) + (draw-thruster (_type_ vector vector float float) none 84) + (draw-thrusters (_type_) none 85) + (update-joint-mods (_type_) none 86) (vehicle-method-87 (_type_) none 87) (vehicle-method-88 (_type_) none 88) (vehicle-method-89 (_type_) none 89) diff --git a/test/decompiler/reference/jak2/levels/city/common/vehicle-physics_REF.gc b/test/decompiler/reference/jak2/levels/city/common/vehicle-physics_REF.gc index 9148880d05..3960110fbf 100644 --- a/test/decompiler/reference/jak2/levels/city/common/vehicle-physics_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/vehicle-physics_REF.gc @@ -743,7 +743,7 @@ ) ) ) - (let ((s1-4 (new 'stack-no-clear 'inline-array 'vehicle-control-point 2))) + (let ((s1-4 (new 'stack-no-clear 'inline-array 'vehicle-control-point 24))) (quad-copy! (the-as pointer s1-4) (the-as pointer (-> s4-0 stabilizer-array)) diff --git a/test/decompiler/reference/jak2/levels/city/common/vehicle-rider_REF.gc b/test/decompiler/reference/jak2/levels/city/common/vehicle-rider_REF.gc index 05a582b400..a6fc5b154c 100644 --- a/test/decompiler/reference/jak2/levels/city/common/vehicle-rider_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/vehicle-rider_REF.gc @@ -68,7 +68,7 @@ (if (and s5-0 (nonzero? (vehicle-method-72 s5-0))) (logior! (-> obj flags) 4) ) - (vehicle-method-71 s5-0 (-> obj seat-index) obj) + (put-rider-in-seat s5-0 (-> obj seat-index) obj) ) (set! (-> obj anim-speed) (rand-vu-float-range 0.8 1.2)) 0 @@ -80,7 +80,7 @@ (defmethod vehicle-rider-method-35 vehicle-rider ((obj vehicle-rider)) (logior! (-> obj draw status) (draw-control-status no-draw)) (let ((v1-3 (-> obj parent-override))) - (vehicle-method-71 + (put-rider-in-seat (the-as vehicle (if v1-3 (-> v1-3 0 self-override) ) @@ -172,7 +172,7 @@ (('knocked-off) (let ((gp-0 (new 'stack 'traffic-object-spawn-params))) (let ((v1-14 (find-nearest-nav-mesh (-> self root-override trans) (the-as float #x7f800000)))) - (set! (-> gp-0 object-type) (the-as uint 0)) + (set! (-> gp-0 object-type) (traffic-type citizen-norm-1)) (set! (-> gp-0 behavior) (the-as uint 11)) (set! (-> gp-0 id) (the-as uint 0)) (set! (-> gp-0 nav-mesh) v1-14) @@ -186,7 +186,7 @@ (vector-reset! (-> gp-0 velocity)) (when (logtest? (-> self flags) 8) (send-event *traffic-manager* 'increase-alert-level 2) - (set! (-> gp-0 object-type) (the-as uint 6)) + (set! (-> gp-0 object-type) (traffic-type crimson-guard-1)) ) (set! (-> gp-0 position quad) (-> self root-override trans quad)) (quaternion-copy! (-> gp-0 rotation) (-> self root-override quat)) diff --git a/test/decompiler/reference/jak2/levels/city/common/vehicle-states_REF.gc b/test/decompiler/reference/jak2/levels/city/common/vehicle-states_REF.gc index bcdcc6ebf3..e94698c5a6 100644 --- a/test/decompiler/reference/jak2/levels/city/common/vehicle-states_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/vehicle-states_REF.gc @@ -429,7 +429,7 @@ ) (send-event-function (handle->process (-> self rider-array gp-1)) a1-2) ) - (vehicle-method-71 self gp-1 (the-as process-focusable #f)) + (put-rider-in-seat self gp-1 (the-as process-focusable #f)) ) (logior! (-> self focus-status) (focus-status dead)) (set! (-> self crash-level) 3) diff --git a/test/decompiler/reference/jak2/levels/city/common/vehicle-util_REF.gc b/test/decompiler/reference/jak2/levels/city/common/vehicle-util_REF.gc index 75911adb7e..560f19c664 100644 --- a/test/decompiler/reference/jak2/levels/city/common/vehicle-util_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/vehicle-util_REF.gc @@ -297,9 +297,9 @@ This commonly includes things such as: (s4-1 #f) (s3-0 #f) ) - (let ((a2-2 (vehicle-method-73 obj (-> s5-0 matrices 0 vector 1) 1 0))) + (let ((a2-2 (get-best-seat-for-vehicle obj (-> s5-0 matrices 0 vector 1) 1 0))) (when (!= a2-2 -1) - (vehicle-method-68 obj (-> s5-0 matrices 0 vector 2) a2-2) + (compute-seat-position obj (-> s5-0 matrices 0 vector 2) a2-2) (vector+float*! (-> s5-0 matrices 0 vector 2) (-> s5-0 matrices 0 vector 2) @@ -503,7 +503,7 @@ This commonly includes things such as: ;; definition for method 65 of type vehicle ;; WARN: Return type mismatch int vs none. -(defmethod vehicle-method-65 vehicle ((obj vehicle)) +(defmethod start-jump vehicle ((obj vehicle)) (when (logtest? (-> obj info-override flags) 16) (when (not (logtest? (rigid-body-object-flag jump-sound) (-> obj flags))) (set! (-> obj flags) (logior (rigid-body-object-flag jump-sound) (-> obj flags))) @@ -523,16 +523,14 @@ This commonly includes things such as: ) ;; definition for method 67 of type vehicle -;; WARN: Return type mismatch int vs none. -(defmethod vehicle-method-67 vehicle ((obj vehicle)) +(defmethod get-seat-count vehicle ((obj vehicle)) (-> obj info-override seat-count) - (none) ) ;; definition for method 68 of type vehicle ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -(defmethod vehicle-method-68 vehicle ((obj vehicle) (arg0 vector) (arg1 int)) +(defmethod compute-seat-position vehicle ((obj vehicle) (arg0 vector) (arg1 int)) (let ((v1-0 (new 'stack-no-clear 'vector))) (set! (-> v1-0 quad) (-> obj info-override seat-array arg1 position quad)) (set! (-> v1-0 w) 1.0) @@ -543,7 +541,7 @@ This commonly includes things such as: ) ;; definition for method 69 of type vehicle -(defmethod vehicle-method-69 vehicle ((obj vehicle) (arg0 int)) +(defmethod get-rider-in-seat vehicle ((obj vehicle) (arg0 int)) (let ((v0-0 (the-as process #f))) (if (< arg0 (-> obj info-override seat-count)) (set! v0-0 (handle->process (-> obj rider-array arg0))) @@ -557,7 +555,7 @@ This commonly includes things such as: (let ((gp-0 (the-as process #f))) (countdown (s4-0 (-> obj info-override seat-count)) (when (logtest? (-> obj info-override seat-array s4-0 flags) 1) - (let ((v1-7 (vehicle-method-69 obj s4-0))) + (let ((v1-7 (get-rider-in-seat obj s4-0))) (if v1-7 (set! gp-0 v1-7) ) @@ -569,7 +567,7 @@ This commonly includes things such as: ) ;; definition for method 73 of type vehicle -(defmethod vehicle-method-73 vehicle ((obj vehicle) (arg0 vector) (arg1 int) (arg2 int)) +(defmethod get-best-seat-for-vehicle vehicle ((obj vehicle) (arg0 vector) (arg1 int) (arg2 int)) (let ((gp-0 -1)) (let ((f30-0 (the-as float #x7f800000)) (s1-0 (new 'stack-no-clear 'vector)) @@ -582,16 +580,16 @@ This commonly includes things such as: #t ) ((= v1-7 1) - (not (vehicle-method-69 obj s0-0)) + (not (get-rider-in-seat obj s0-0)) ) ((= v1-7 2) - (vehicle-method-69 obj s0-0) + (get-rider-in-seat obj s0-0) ) (else #f ) ) - (vehicle-method-68 obj s1-0 s0-0) + (compute-seat-position obj s1-0 s0-0) (let ((f0-0 (vector-vector-distance-squared arg0 s1-0))) (when (< f0-0 f30-0) (set! f30-0 f0-0) @@ -609,7 +607,7 @@ This commonly includes things such as: ;; definition for method 74 of type vehicle ;; WARN: Return type mismatch int vs none. -(defmethod vehicle-method-74 vehicle ((obj vehicle) (arg0 process)) +(defmethod remove-rider vehicle ((obj vehicle) (arg0 process)) (let ((v1-1 (-> obj info-override seat-count))) (dotimes (a2-0 v1-1) (if (= arg0 (handle->process (-> obj rider-array a2-0))) @@ -623,7 +621,7 @@ This commonly includes things such as: ;; definition for method 71 of type vehicle ;; WARN: Return type mismatch int vs none. -(defmethod vehicle-method-71 vehicle ((obj vehicle) (arg0 int) (arg1 process-focusable)) +(defmethod put-rider-in-seat vehicle ((obj vehicle) (arg0 int) (arg1 process-focusable)) (if (< arg0 (-> obj info-override seat-count)) (set! (-> obj rider-array arg0) (process->handle arg1)) ) @@ -786,7 +784,7 @@ This commonly includes things such as: (set! (-> obj power-level) 1.0) (set! (-> obj flight-level-index) 0) (let ((a1-0 (-> obj root-override-2 trans))) - (set! (-> obj flight-level) (xz-height-map-method-9 *traffic-height-map* a1-0)) + (set! (-> obj flight-level) (get-height-at-point *traffic-height-map* a1-0)) ) (set! (-> obj lights-factor) 0.0) (let ((a0-8 (-> obj info-override color-option-select))) @@ -1220,7 +1218,7 @@ This commonly includes things such as: (let ((a0-1 (-> obj controller traffic))) (when (and (nonzero? a0-1) arg1) (if #t - (increase-alert-level a0-1 arg0 arg1) + (increase-alert-level a0-1 (the-as int arg0) arg1) ) ) ) @@ -1231,7 +1229,7 @@ This commonly includes things such as: ;; definition for method 112 of type vehicle ;; WARN: Return type mismatch int vs none. (defmethod vehicle-method-112 vehicle ((obj vehicle) (arg0 object)) - (decrease-alert-level (-> obj controller traffic) arg0) + (decrease-alert-level (-> obj controller traffic) (the-as int arg0)) 0 (none) ) @@ -1416,7 +1414,7 @@ This commonly includes things such as: ) ) (dotimes (s5-1 (-> obj info-override seat-count)) - (vehicle-method-71 obj s5-1 (the-as process-focusable #f)) + (put-rider-in-seat obj s5-1 (the-as process-focusable #f)) ) (vehicle-method-142 obj) (vehicle-controller-method-11 (-> obj controller)) @@ -1553,7 +1551,7 @@ This commonly includes things such as: ;; definition for method 86 of type vehicle ;; WARN: Return type mismatch int vs none. -(defmethod vehicle-method-86 vehicle () +(defmethod update-joint-mods vehicle ((obj vehicle)) 0 (none) ) @@ -1570,7 +1568,7 @@ This commonly includes things such as: (set! (-> s5-0 local-pos w) 40960.0) (let ((s4-0 0)) (label cfg-1) - (let ((v1-7 (traffic-engine-method-20 (-> obj controller traffic) (-> s5-0 local-pos) (-> s5-0 normal) 0))) + (let ((v1-7 (find-best-segment (-> obj controller traffic) (-> s5-0 local-pos) (-> s5-0 normal) 0))) (when (and (not v1-7) (< s4-0 3)) (set! (-> s5-0 local-pos w) (+ 40960.0 (-> s5-0 local-pos w))) (+! s4-0 1) @@ -1594,7 +1592,7 @@ This commonly includes things such as: (dotimes (s5-0 (-> obj info-override seat-count)) (let ((s4-0 (handle->process (-> obj rider-array s5-0)))) (when (and s4-0 (logtest? (-> (the-as vehicle-rider s4-0) focus-status) (focus-status pilot-riding))) - (vehicle-method-68 obj (-> (the-as vehicle-rider s4-0) root-override trans) s5-0) + (compute-seat-position obj (-> (the-as vehicle-rider s4-0) root-override trans) s5-0) (set! (-> (the-as vehicle-rider s4-0) root-override transv quad) (-> obj root-override-2 transv quad)) (let ((f0-1 (the float (-> obj info-override seat-array s5-0 angle)))) (quaternion-rotate-local-y! diff --git a/test/decompiler/reference/jak2/levels/city/common/vehicle_REF.gc b/test/decompiler/reference/jak2/levels/city/common/vehicle_REF.gc index e57a3cb2b1..491bb9d5a6 100644 --- a/test/decompiler/reference/jak2/levels/city/common/vehicle_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/vehicle_REF.gc @@ -208,7 +208,7 @@ (with-pp (when (= (-> obj controller traffic sync-mask-8) (ash 1 (logand (-> obj traffic-priority-id) 7))) (let ((a1-0 (-> obj root-override-2 trans))) - (set! (-> obj flight-level) (xz-height-map-method-9 *traffic-height-map* a1-0)) + (set! (-> obj flight-level) (get-height-at-point *traffic-height-map* a1-0)) ) ) (set! (-> obj target-acceleration y) @@ -417,7 +417,7 @@ (vehicle-method-95 obj (the-as vector (&-> s5-0 x))) ) (if (or (cpad-hold? 0 l1) (and (logtest? (-> obj info-override flags) 512) (cpad-hold? 0 r1))) - (vehicle-method-65 obj) + (start-jump obj) ) (if (cpad-pressed? 0 circle) ((method-of-object obj vehicle-method-66)) @@ -620,10 +620,10 @@ (dotimes (v1-4 (-> *level* length)) (let ((a0-5 (-> *level* level v1-4))) (when (= (-> a0-5 status) 'active) - (let ((a0-7 (-> a0-5 bsp bsp-header-jkh1b23))) + (let ((a0-7 (-> a0-5 bsp city-level-info))) (when (nonzero? a0-7) - (let ((f1-0 (-> a0-7 frames-per-second))) - (if (= f1-0 0.0) + (let ((f1-0 (the-as float (-> a0-7 camera-ceiling)))) + (if (= (the-as meters f1-0) 0.0) (set! f1-0 40960000.0) ) (set! f0-0 (fmax f0-0 f1-0)) @@ -943,18 +943,18 @@ (f1-0 245760.0) ) (if (< f0-1 (* f1-0 f1-0)) - (rigid-body-object-method-36 obj) + (do-engine-sounds obj) ) ) (when (logtest? (-> obj draw status) (draw-control-status on-screen)) (if #t - (vehicle-method-85 obj) + (draw-thrusters obj) ) (let ((f0-2 (-> obj camera-dist2)) (f1-3 245760.0) ) (if (< f0-2 (* f1-3 f1-3)) - ((method-of-object obj vehicle-method-86)) + (update-joint-mods obj) ) ) ) @@ -1031,7 +1031,7 @@ ) (vehicle-method-96 obj) (let ((a1-0 (-> obj rbody state position))) - (set! (-> obj flight-level) (xz-height-map-method-9 *traffic-height-map* a1-0)) + (set! (-> obj flight-level) (get-height-at-point *traffic-height-map* a1-0)) ) 0 (none) @@ -1321,13 +1321,13 @@ (let ((f0-10 (vector-length (-> obj root-override-2 transv)))) (seek! (-> obj engine-power-factor) (* 0.000016276043 f0-10) (* 6.0 (-> pp clock seconds-per-frame))) ) - (rigid-body-object-method-36 obj) + (do-engine-sounds obj) ) ) (when (logtest? (-> obj draw status) (draw-control-status on-screen)) (when #t (set! (-> obj node-list data 0 bone transform trans quad) (-> obj root-override-2 trans quad)) - (vehicle-method-85 obj) + (draw-thrusters obj) ) ) (let ((v1-70 (-> *perf-stats* data 19))) @@ -1407,7 +1407,7 @@ ;; definition for method 31 of type vehicle ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-31 vehicle ((obj vehicle) (arg0 rigid-body-vehicle-constants)) +(defmethod alloc-and-init-rigid-body-control vehicle ((obj vehicle) (arg0 rigid-body-vehicle-constants)) (if (logtest? (-> arg0 flags) 8) (iterate-prims (-> obj root-override-2) @@ -1493,7 +1493,7 @@ (new 'static 'pat-surface :noentity #x1 :nopilot #x1 :probe #x1) ) (set! (-> obj root-override-2 event-self) 'touched) - (let ((t9-3 (method-of-type rigid-body-object rigid-body-object-method-31))) + (let ((t9-3 (method-of-type rigid-body-object alloc-and-init-rigid-body-control))) (t9-3 obj arg0) ) (logior! (-> obj rbody state flags) (rigid-body-flag enable-collision)) @@ -1913,7 +1913,7 @@ (when s5-3 (format #t "vehicle::event-handler: pilot-on (pid ~d) from pid ~d~%" (-> obj pid) (-> arg0 pid)) (logior! (-> obj flags) (rigid-body-object-flag riding)) - (vehicle-method-71 obj (the-as int s3-2) (the-as process-focusable s5-3)) + (put-rider-in-seat obj (the-as int s3-2) (the-as process-focusable s5-3)) (if (logtest? (-> s5-3 mask) (process-mask target)) (logior! (-> obj flags) (rigid-body-object-flag player-driving)) ) @@ -1954,13 +1954,13 @@ (defbehavior vehicle-init-by-other vehicle ((arg0 traffic-object-spawn-params)) (stack-size-set! (-> self main-thread) 16) (set! (-> self mask) (logior (process-mask vehicle) (-> self mask))) - (rigid-body-object-method-32 self) + (allocate-and-init-cshape self) (set! (-> self root-override-2 trans quad) (-> arg0 position quad)) (quaternion-copy! (-> self root-override-2 quat) (-> arg0 rotation)) (if (not (logtest? (-> arg0 flags) 1)) (lwide-entity-hack) ) - (rigid-body-object-method-33 self) + (init-skel-and-rigid-body self) (set! (-> self traffic-priority-id) (the-as int (-> arg0 id))) (vehicle-method-136 self arg0) (none) diff --git a/test/decompiler/reference/jak2/levels/city/misc/collection_task/collection-task_REF.gc b/test/decompiler/reference/jak2/levels/city/misc/collection_task/collection-task_REF.gc index 86b1ecc967..533ba2194d 100644 --- a/test/decompiler/reference/jak2/levels/city/misc/collection_task/collection-task_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/misc/collection_task/collection-task_REF.gc @@ -241,7 +241,7 @@ ) (set! (-> traffic-obj-params position quad) (-> self begin-pos quad)) (quaternion-axis-angle! (-> traffic-obj-params rotation) 0.0 1.0 0.0 16384.0) - (set! (-> traffic-obj-params object-type) (the-as uint 13)) + (set! (-> traffic-obj-params object-type) (traffic-type bikec)) (set! (-> traffic-obj-params behavior) (the-as uint 0)) (set! (-> traffic-obj-params id) (the-as uint 0)) (set! (-> traffic-obj-params proc) #f) diff --git a/test/decompiler/reference/jak2/levels/city/misc/delivery/delivery-task_REF.gc b/test/decompiler/reference/jak2/levels/city/misc/delivery/delivery-task_REF.gc index 8a2fc1eb43..aaa21a77d1 100644 --- a/test/decompiler/reference/jak2/levels/city/misc/delivery/delivery-task_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/misc/delivery/delivery-task_REF.gc @@ -136,6 +136,7 @@ This commonly includes things such as: ) ;; definition for function krew-package-spawn +;; WARN: Return type mismatch (pointer process) vs (pointer krew-package). (defun krew-package-spawn ((arg0 process) (arg1 process)) (process-spawn krew-package arg1 :to arg0) ) @@ -163,7 +164,7 @@ This commonly includes things such as: (let ((s5-0 (new 'stack 'traffic-object-spawn-params))) (set! (-> s5-0 position quad) (-> (new 'static 'vector :x 4698112.0 :y 45875.2 :z 81920.0 :w 1.0) quad)) (quaternion-axis-angle! (-> s5-0 rotation) 0.0 1.0 0.0 32768.0) - (set! (-> s5-0 object-type) (the-as uint 11)) + (set! (-> s5-0 object-type) (traffic-type bikea)) (set! (-> s5-0 behavior) (the-as uint 0)) (set! (-> s5-0 id) (the-as uint 0)) (set! (-> s5-0 proc) #f) @@ -271,7 +272,7 @@ This commonly includes things such as: ) (s5-0 (new 'stack-no-clear 'traffic-object-spawn-params)) ) - (set! (-> s5-0 object-type) (the-as uint 6)) + (set! (-> s5-0 object-type) (traffic-type crimson-guard-1)) (set! (-> s5-0 behavior) (the-as uint 9)) (set! (-> s5-0 id) (the-as uint 0)) (set! (-> s5-0 nav-mesh) #f) @@ -344,7 +345,7 @@ This commonly includes things such as: ) (s5-0 (new 'stack-no-clear 'traffic-object-spawn-params)) ) - (set! (-> s5-0 object-type) (the-as uint 6)) + (set! (-> s5-0 object-type) (traffic-type crimson-guard-1)) (set! (-> s5-0 behavior) (the-as uint 9)) (set! (-> s5-0 id) (the-as uint 0)) (set! (-> s5-0 nav-mesh) #f) @@ -567,7 +568,3 @@ This commonly includes things such as: ) ) ) - - - - diff --git a/test/decompiler/reference/jak2/levels/city/port/mines/portrun_REF.gc b/test/decompiler/reference/jak2/levels/city/port/mines/portrun_REF.gc index 53cb0547d6..5814c9a64d 100644 --- a/test/decompiler/reference/jak2/levels/city/port/mines/portrun_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/port/mines/portrun_REF.gc @@ -1806,7 +1806,7 @@ ) (set! (-> s5-0 position quad) (-> self begin-pos quad)) (quaternion-axis-angle! (-> s5-0 rotation) 0.0 1.0 0.0 0.0) - (set! (-> s5-0 object-type) (the-as uint 13)) + (set! (-> s5-0 object-type) (traffic-type bikec)) (set! (-> s5-0 behavior) (the-as uint 0)) (set! (-> s5-0 id) (the-as uint 0)) (set! (-> s5-0 proc) #f) diff --git a/test/decompiler/reference/jak2/levels/city/side_missions/ctywide-bbush_REF.gc b/test/decompiler/reference/jak2/levels/city/side_missions/ctywide-bbush_REF.gc index 7f54995b94..d3f2514ea3 100644 --- a/test/decompiler/reference/jak2/levels/city/side_missions/ctywide-bbush_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/side_missions/ctywide-bbush_REF.gc @@ -1495,7 +1495,7 @@ ) (set! (-> gp-0 position quad) (-> *bb-ring-info* (-> self info index) start-pos quad)) (quaternion-axis-angle! (-> gp-0 rotation) 0.0 1.0 0.0 (-> *bb-ring-info* (-> self info index) rotation)) - (set! (-> gp-0 object-type) (the-as uint 11)) + (set! (-> gp-0 object-type) (traffic-type bikea)) (set! (-> gp-0 behavior) (the-as uint 0)) (set! (-> gp-0 id) (the-as uint 0)) (set! (-> gp-0 proc) #f) @@ -1925,16 +1925,19 @@ This commonly includes things such as: ) ;; definition for function bush-collect-spawn +;; WARN: Return type mismatch (pointer process) vs (pointer bush-collect). (defun bush-collect-spawn ((arg0 task-manager) (arg1 vector)) (process-spawn bush-collect arg1 :to arg0) ) ;; definition for function bush-collect-homing-beacon-spawn +;; WARN: Return type mismatch (pointer process) vs (pointer bush-collect). (defun bush-collect-homing-beacon-spawn ((arg0 task-manager) (arg1 vector)) (process-spawn bush-collect :init bush-collect-homing-beacon-init-by-other arg1 :to arg0) ) ;; definition for function bush-collect-dark-eco-spawn +;; WARN: Return type mismatch (pointer process) vs (pointer bush-collect). (defun bush-collect-dark-eco-spawn ((arg0 task-manager) (arg1 vector)) (process-spawn bush-collect :init bush-collect-dark-eco-init-by-other arg1 :to arg0) ) @@ -3309,7 +3312,3 @@ This commonly includes things such as: 0 (none) ) - - - - diff --git a/test/decompiler/reference/jak2/levels/common/enemy/bombots/bombbot_REF.gc b/test/decompiler/reference/jak2/levels/common/enemy/bombots/bombbot_REF.gc index 5d073e7c11..6a1eafff3e 100644 --- a/test/decompiler/reference/jak2/levels/common/enemy/bombots/bombbot_REF.gc +++ b/test/decompiler/reference/jak2/levels/common/enemy/bombots/bombbot_REF.gc @@ -914,7 +914,7 @@ (set! (-> a1-0 decay-rate) 0.0) (set! (-> a1-0 flags) (traffic-danger-flags tdf0)) (set! (-> a1-0 danger-type) (traffic-danger-type tdt0)) - (add-danger-sphere *traffic-engine* a1-0) + (add-danger *traffic-engine* a1-0) ) (none) ) diff --git a/test/decompiler/reference/jak2/levels/dig/dig-obs_REF.gc b/test/decompiler/reference/jak2/levels/dig/dig-obs_REF.gc index 3366fe24b0..1fb63681da 100644 --- a/test/decompiler/reference/jak2/levels/dig/dig-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/dig/dig-obs_REF.gc @@ -56,7 +56,7 @@ ;; definition for method 32 of type dig-sinking-plat ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-32 dig-sinking-plat ((obj dig-sinking-plat)) +(defmethod allocate-and-init-cshape dig-sinking-plat ((obj dig-sinking-plat)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -267,13 +267,13 @@ ;; definition for method 33 of type dig-sinking-plat ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-33 dig-sinking-plat ((obj dig-sinking-plat)) +(defmethod init-skel-and-rigid-body dig-sinking-plat ((obj dig-sinking-plat)) (initialize-skeleton obj (the-as skeleton-group (art-group-get-by-name *level* "skel-dig-sinking-plat" (the-as (pointer uint32) #f))) (the-as pair 0) ) - (rigid-body-object-method-31 obj *dig-sinking-platform-constants*) + (alloc-and-init-rigid-body-control obj *dig-sinking-platform-constants*) (set! (-> obj anchor-point quad) (-> obj root-override-2 trans quad)) (set! (-> obj surface-height) (+ -4096.0 (-> obj root-override-2 trans y))) (let ((s5-1 (-> obj info-override control-point-count))) diff --git a/test/decompiler/reference/jak2/levels/dig/dig1-obs_REF.gc b/test/decompiler/reference/jak2/levels/dig/dig1-obs_REF.gc index fd21a8c8d1..5364e76ae3 100644 --- a/test/decompiler/reference/jak2/levels/dig/dig1-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/dig/dig1-obs_REF.gc @@ -784,7 +784,7 @@ ;; definition for method 32 of type dig-bomb-crate-cylinder ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-32 dig-bomb-crate-cylinder ((obj dig-bomb-crate-cylinder)) +(defmethod allocate-and-init-cshape dig-bomb-crate-cylinder ((obj dig-bomb-crate-cylinder)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -835,7 +835,7 @@ ;; definition for method 33 of type dig-bomb-crate-cylinder ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-33 dig-bomb-crate-cylinder ((obj dig-bomb-crate-cylinder)) +(defmethod init-skel-and-rigid-body dig-bomb-crate-cylinder ((obj dig-bomb-crate-cylinder)) (initialize-skeleton obj (the-as @@ -844,7 +844,7 @@ ) (the-as pair 0) ) - (rigid-body-object-method-31 obj *dig-bomb-crate-cylinder-constants*) + (alloc-and-init-rigid-body-control obj *dig-bomb-crate-cylinder-constants*) (logclear! (-> obj mask) (process-mask actor-pause)) (logior! (-> obj rbody state flags) (rigid-body-flag enable-collision)) (set! (-> obj draw light-index) (the-as uint 10)) @@ -857,10 +857,10 @@ ;; WARN: Return type mismatch object vs none. (defbehavior dig-bomb-crate-cylinder-init-by-other dig-bomb-crate-cylinder ((arg0 dig-bomb-crate-cylinder-spawn-params) (arg1 entity-actor)) (process-entity-set! self arg1) - (rigid-body-object-method-32 self) + (allocate-and-init-cshape self) (set! (-> self root-override-2 trans quad) (-> arg0 pos quad)) (quaternion-copy! (-> self root-override-2 quat) (-> arg0 quat)) - (rigid-body-object-method-33 self) + (init-skel-and-rigid-body self) (set! (-> self mask) (logior (process-mask platform) (-> self mask))) (vector-float*! (-> self rbody state lin-momentum) (-> arg0 vel) (-> self info info mass)) (vector-float*! (-> self rbody state ang-momentum) (-> arg0 avel) (-> self info info mass)) diff --git a/test/decompiler/reference/jak2/levels/dig/dig3-obs_REF.gc b/test/decompiler/reference/jak2/levels/dig/dig3-obs_REF.gc index 0351074e4f..cb9b6d48c0 100644 --- a/test/decompiler/reference/jak2/levels/dig/dig3-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/dig/dig3-obs_REF.gc @@ -1610,7 +1610,7 @@ This commonly includes things such as: ;; definition for method 32 of type dig-tipping-rock ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-32 dig-tipping-rock ((obj dig-tipping-rock)) +(defmethod allocate-and-init-cshape dig-tipping-rock ((obj dig-tipping-rock)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -1646,14 +1646,14 @@ This commonly includes things such as: ;; definition for method 33 of type dig-tipping-rock ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-33 dig-tipping-rock ((obj dig-tipping-rock)) +(defmethod init-skel-and-rigid-body dig-tipping-rock ((obj dig-tipping-rock)) (initialize-skeleton obj (the-as skeleton-group (art-group-get-by-name *level* "skel-dig-tipping-rock" (the-as (pointer uint32) #f))) (the-as pair 0) ) (quaternion-rotate-local-x! (-> obj root-override-2 quat) (-> obj root-override-2 quat) -2555.2202) - (rigid-body-object-method-31 obj *dig-tipping-rock-constants*) + (alloc-and-init-rigid-body-control obj *dig-tipping-rock-constants*) (set! (-> obj anchor-point quad) (-> obj rbody state position quad)) (let ((v1-8 (-> obj control-point-array))) (let ((a0-8 (-> v1-8 data))) @@ -1990,7 +1990,7 @@ This commonly includes things such as: ;; definition for method 32 of type dig-stomp-block ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-32 dig-stomp-block ((obj dig-stomp-block)) +(defmethod allocate-and-init-cshape dig-stomp-block ((obj dig-stomp-block)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -2087,13 +2087,13 @@ This commonly includes things such as: ;; definition for method 33 of type dig-stomp-block ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-33 dig-stomp-block ((obj dig-stomp-block)) +(defmethod init-skel-and-rigid-body dig-stomp-block ((obj dig-stomp-block)) (initialize-skeleton obj (the-as skeleton-group (art-group-get-by-name *level* "skel-dig-stomp-block" (the-as (pointer uint32) #f))) (the-as pair 0) ) - (rigid-body-object-method-31 obj *dig-stomp-block-constants*) + (alloc-and-init-rigid-body-control obj *dig-stomp-block-constants*) (logclear! (-> obj mask) (process-mask actor-pause)) (logior! (-> obj rbody state flags) (rigid-body-flag enable-collision)) (set! (-> obj draw light-index) (the-as uint 10)) @@ -2107,10 +2107,10 @@ This commonly includes things such as: ;; WARN: Return type mismatch object vs none. (defbehavior dig-stomp-block-init-by-other dig-stomp-block ((arg0 vector)) (set! (-> self mask) (logior (process-mask platform) (-> self mask))) - (rigid-body-object-method-32 self) + (allocate-and-init-cshape self) (set! (-> self root-override-2 trans quad) (-> arg0 quad)) (set-vector! (-> self root-override-2 quat) 0.0 1.0 0.0 0.0) - (rigid-body-object-method-33 self) + (init-skel-and-rigid-body self) (transform-post) (go-virtual waiting) (none) diff --git a/test/decompiler/reference/jak2/levels/ruins/ruins-obs_REF.gc b/test/decompiler/reference/jak2/levels/ruins/ruins-obs_REF.gc index 1790b1aca7..2ecf5d2f86 100644 --- a/test/decompiler/reference/jak2/levels/ruins/ruins-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/ruins/ruins-obs_REF.gc @@ -42,7 +42,7 @@ ;; definition for method 32 of type sinking-plat ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-32 sinking-plat ((obj sinking-plat)) +(defmethod allocate-and-init-cshape sinking-plat ((obj sinking-plat)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -107,14 +107,14 @@ ;; definition for method 33 of type sinking-plat ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-33 sinking-plat ((obj sinking-plat)) +(defmethod init-skel-and-rigid-body sinking-plat ((obj sinking-plat)) (initialize-skeleton obj (the-as skeleton-group (art-group-get-by-name *level* "skel-sinking-plat" (the-as (pointer uint32) #f))) (the-as pair 0) ) (set! (-> obj float-height-offset) 4096.0) - (rigid-body-object-method-31 obj *ruins-sinking-platform-constants*) + (alloc-and-init-rigid-body-control obj *ruins-sinking-platform-constants*) (set! (-> obj anchor-point quad) (-> obj root-override-2 trans quad)) (let ((s5-1 (-> obj info-override control-point-count))) (dotimes (s4-1 s5-1) diff --git a/test/decompiler/reference/jak2/levels/underport/under-obs_REF.gc b/test/decompiler/reference/jak2/levels/underport/under-obs_REF.gc index 0059b55371..5e2d706f5f 100644 --- a/test/decompiler/reference/jak2/levels/underport/under-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/underport/under-obs_REF.gc @@ -1013,7 +1013,7 @@ This commonly includes things such as: ;; definition for method 32 of type under-buoy-plat ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-32 under-buoy-plat ((obj under-buoy-plat)) +(defmethod allocate-and-init-cshape under-buoy-plat ((obj under-buoy-plat)) (let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player)))) (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) (set! (-> s5-0 reaction) cshape-reaction-default) @@ -1104,13 +1104,13 @@ This commonly includes things such as: ;; definition for method 33 of type under-buoy-plat ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -(defmethod rigid-body-object-method-33 under-buoy-plat ((obj under-buoy-plat)) +(defmethod init-skel-and-rigid-body under-buoy-plat ((obj under-buoy-plat)) (initialize-skeleton obj (the-as skeleton-group (art-group-get-by-name *level* "skel-under-buoy-plat" (the-as (pointer uint32) #f))) (the-as pair 0) ) - (rigid-body-object-method-31 obj *under-buoy-plat-platform-constants*) + (alloc-and-init-rigid-body-control obj *under-buoy-plat-platform-constants*) (set! (-> obj orig-trans quad) (-> obj root-override-2 trans quad)) (set! (-> obj anchor-point quad) (-> obj root-override-2 trans quad)) (set! (-> obj surface-height) (-> obj root-override-2 trans y)) diff --git a/test/offline/config/jak2/config.jsonc b/test/offline/config/jak2/config.jsonc index 5148431126..ddf2811315 100644 --- a/test/offline/config/jak2/config.jsonc +++ b/test/offline/config/jak2/config.jsonc @@ -296,7 +296,10 @@ "(method 193 grunt-mech)", // .mula.s "(method 3 sig-path-sample)", "debug-eyes", // unused debug function - "(method 11 pal-grind-ring-center)" // same thing defined twice + "(method 11 pal-grind-ring-center)", // same thing defined twice + "(method 49 traffic-engine)", // float stuff + "(method 14 nav-graph)", + "target-pilot-init" ], "skip_compile_states": { @@ -311,6 +314,7 @@ "(fall ruins-pillar-collapse)": ["code"], // missing cast to art-joint-anim "(hit drill-wall)": ["code"], // missing cast to art-joint-anim "(hit drill-crane)": ["code"], // missing cast to art-joint-anim - "(hit under-break-door)": ["code"] // missing cast to art-joint-anim + "(hit under-break-door)": ["code"], // missing cast to art-joint-anim + "(target-pilot-get-on target)": ["trans"] // missint cast } }