Files
jak-project/goal_src/levels/common/plat-button.gc
T
Ziemas 766b328c97 Overlord sound player (#1239)
* Accept player RPC commands in overlord

* Remove the .projectile file

I use emacs for everything so I don't want it to only look at the goal code.

* Fill out most of the unique player structs

* Decompile most of ssound.c

* Silence some spam

* Comment out WaitSema instance

* Add a file with definitions for snd_ functions

Makes it compile without commenting them out.

Maybe it'd be nice to maintain the original API usage in overlord for
similarity and shim them to whatever API the player uses.

* Make SoundBank statically sized again.

Didn't realise this was used in an array. MSVC should be happy again.

Not sure what the actual size of these should be.

* Fix logic issue

* Finish RPC Loader

* More RPC_Player

* Play RPC command

* All the RPC commands added

* Call Music/Bank loaders

* audio: add almost all `.MUS` and `.SBK` files to build process

* Include TWEAKVAL in build output

* Load banks and music tweaks

* Comment out spam

* Sound struct unk -> is music

* Also test if empty1.sbk was found

For the sake of tests.

* Get rid of PC_DEBUG_SOUND_ENABLE

Co-authored-by: Tyler Wilding <xtvaser@gmail.com>
2022-03-22 18:53:36 -04:00

533 lines
19 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: plat-button.gc
;; name in dgo: plat-button
;; dgos: GAME, COMMON, L1
;; DECOMP BEGINS
(deftype plat-button (process-drawable)
((root-override collide-shape-moving :offset 112)
(go-back-if-lost-player? symbol :offset-assert 176)
(grab-player? symbol :offset-assert 180)
(should-grab-player? symbol :offset-assert 184)
(path-pos float :offset-assert 188)
(bidirectional? symbol :offset-assert 192)
(allow-auto-kill symbol :offset-assert 196)
(sound-id sound-id :offset-assert 200)
(trans-off vector :inline :offset-assert 208)
(spawn-pos vector :inline :offset-assert 224)
)
:heap-base #x80
:method-count-assert 33
:size-assert #xf0
:flag-assert #x21008000f0
(:methods
(plat-button-at-end () _type_ :state 20)
(plat-button-idle () _type_ :state 21)
(plat-button-pressed () _type_ :state 22)
(plat-button-move-downward () _type_ :state 23)
(plat-button-move-upward () _type_ :state 24)
(plat-button-teleport-to-other-end () _type_ :state 25)
(can-activate? (_type_) symbol 26)
(TODO-RENAME-27 (_type_) none 27)
(TODO-RENAME-28 (_type_) collide-shape-moving 28)
(can-target-move? (_type_) none 29)
(should-teleport? (_type_) symbol 30)
(TODO-RENAME-31 (_type_) none 31)
(TODO-RENAME-32 (_type_) none 32)
)
)
(defskelgroup *plat-button-sg* plat-button
0
2
((1 (meters 999999)))
:bounds (static-spherem 0 -1 0 6.6)
:longest-edge (meters 0)
)
(defmethod should-teleport? plat-button ((obj plat-button))
#f
)
(defmethod can-activate? plat-button ((obj plat-button))
(or (= (-> obj path-pos) 0.0) (and (-> obj bidirectional?) (= (-> obj path-pos) 1.0)))
)
(defstate plat-button-idle (plat-button)
:virtual #t
:event
(behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
(case arg2
(('touch)
(when (can-activate? self)
(if (and ((method-of-type touching-shapes-entry prims-touching?)
(the-as touching-shapes-entry (-> arg3 param 0))
(-> self root-override)
(the-as uint 1)
)
(or (not (-> self should-grab-player?)) (let ((v0-3 (process-grab? *target*)))
(set! (-> self grab-player?) v0-3)
v0-3
)
)
)
(go-virtual plat-button-pressed)
)
)
)
)
)
:code
(behavior ()
(let ((gp-0 (can-activate? self)))
(cond
(gp-0
(let ((a0-1 (-> self skel root-channel 0)))
(set! (-> a0-1 param 0) 0.0)
(set! (-> a0-1 param 1) 1.0)
(joint-control-channel-group! a0-1 (the-as art-joint-anim #f) num-func-seek!)
)
)
(else
(let ((a0-2 (-> self skel root-channel 0)))
(set! (-> a0-2 param 0) (the float (+ (-> a0-2 frame-group data 0 length) -1)))
(set! (-> a0-2 param 1) 1.0)
(joint-control-channel-group! a0-2 (the-as art-joint-anim #f) num-func-seek!)
)
)
)
(while #t
(if (should-teleport? self)
(go-virtual plat-button-teleport-to-other-end)
)
(let ((s5-0 (can-activate? self)))
(when (!= s5-0 gp-0)
(set! gp-0 s5-0)
(cond
(s5-0
(let ((a0-5 (-> self skel root-channel 0)))
(set! (-> a0-5 param 0) 0.0)
(set! (-> a0-5 param 1) 1.0)
(joint-control-channel-group! a0-5 (the-as art-joint-anim #f) num-func-seek!)
)
)
(else
(let ((a0-6 (-> self skel root-channel 0)))
(set! (-> a0-6 param 0) (the float (+ (-> a0-6 frame-group data 0 length) -1)))
(set! (-> a0-6 param 1) 1.0)
(joint-control-channel-group! a0-6 (the-as art-joint-anim #f) num-func-seek!)
)
)
)
)
(when (not (ja-done? 0))
(rider-trans)
(cond
(s5-0
(let ((a0-8 (-> self skel root-channel 0)))
(set! (-> a0-8 param 0) 0.0)
(set! (-> a0-8 param 1) 1.0)
(joint-control-channel-group-eval! a0-8 (the-as art-joint-anim #f) num-func-seek!)
)
)
(else
(let ((a0-9 (-> self skel root-channel 0)))
(set! (-> a0-9 param 0) (the float (+ (-> a0-9 frame-group data 0 length) -1)))
(set! (-> a0-9 param 1) 1.0)
(joint-control-channel-group-eval! a0-9 (the-as art-joint-anim #f) num-func-seek!)
)
)
)
(rider-post)
)
)
(suspend)
)
)
(none)
)
)
(defstate plat-button-teleport-to-other-end (plat-button)
:virtual #t
:code
(behavior ()
(let ((f0-0 1.0))
(if (>= (-> self path-pos) 0.5)
(set! f0-0 0.0)
)
(set! (-> self path-pos) f0-0)
(let ((gp-0 (new 'stack-no-clear 'vector)))
(eval-path-curve! (-> self path) gp-0 f0-0 'interp)
(vector+! gp-0 gp-0 (-> self trans-off))
(move-to-point! (-> self root-override) gp-0)
)
)
(ja-post)
(go-virtual plat-button-idle)
(none)
)
)
(defstate plat-button-pressed (plat-button)
:virtual #t
:trans
(the-as (function none :behavior plat-button) rider-trans)
:code
(behavior ()
(let ((a0-0 (-> self skel root-channel 0)))
(set! (-> a0-0 param 0) (the float (+ (-> a0-0 frame-group data 0 length) -1)))
(set! (-> a0-0 param 1) 1.0)
(joint-control-channel-group! a0-0 (the-as art-joint-anim #f) num-func-seek!)
)
(until (ja-done? 0)
(suspend)
(let ((a0-1 (-> self skel root-channel 0)))
(set! (-> a0-1 param 0) (the float (+ (-> a0-1 frame-group data 0 length) -1)))
(set! (-> a0-1 param 1) 1.0)
(joint-control-channel-group-eval! a0-1 (the-as art-joint-anim #f) num-func-seek!)
)
)
(set! (-> self go-back-if-lost-player?) #t)
(process-entity-status! self (entity-perm-status complete) #t)
(if (= (-> self path-pos) 0.0)
(go-virtual plat-button-move-downward)
(go-virtual plat-button-move-upward)
)
(none)
)
:post
(the-as (function none :behavior plat-button) rider-post)
)
(defbehavior plat-button-camera-on plat-button ()
(let ((v1-1 (res-lump-struct (-> self entity) 'camera-name structure)))
(if v1-1
(send-event *camera* 'change-to-entity-by-name v1-1)
)
)
0
(none)
)
(defbehavior plat-button-camera-off plat-button ()
(send-event *camera* 'clear-entity)
0
(none)
)
(defstate plat-button-move-downward (plat-button)
:virtual #t
:event
(behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
(the-as object (when (or (= arg2 'touch) (= arg2 'attack))
(set! (-> self state-time) (-> *display* base-frame-counter))
#f
)
)
)
:enter
(behavior ()
(set! (-> self state-time) (-> *display* base-frame-counter))
(process-entity-status! self (entity-perm-status bit-3) #t)
(plat-button-camera-on)
(set-setting! *setting-control* self 'allow-look-around #f 0.0 0)
(none)
)
:exit
(behavior ()
(plat-button-camera-off)
(clear-pending-settings-from-process *setting-control* self 'allow-look-around)
(none)
)
:trans
(behavior ()
(if (= (-> self path-pos) 1.0)
(go-virtual plat-button-at-end)
)
(rider-trans)
(when (-> self go-back-if-lost-player?)
(when (or (not *target*) (and (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 4))
(not (and (logtest? (-> *target* control unknown-surface00 flags) 2048)
(zero? (logand (-> *target* control status) 1))
)
)
)
)
(set! (-> self go-back-if-lost-player?) #f)
(go-virtual plat-button-move-upward)
)
)
(let ((f0-4 (seek-with-smooth (-> self path-pos) 1.0 (* 0.1 (-> *display* seconds-per-frame)) 0.25 0.001)))
(set! (-> self path-pos) f0-4)
(let ((gp-0 (new 'stack-no-clear 'vector)))
(eval-path-curve! (-> self path) gp-0 f0-4 'interp)
(vector+! gp-0 gp-0 (-> self trans-off))
(move-to-point! (-> self root-override) gp-0)
)
)
(sound-play-by-name (static-sound-name "elev-loop") (-> self sound-id) 1024 0 0 1 #t)
(let ((gp-1 (the-as sound-rpc-set-param (get-sound-buffer-entry))))
(set! (-> gp-1 command) (sound-command set-param))
(set! (-> gp-1 id) (-> self sound-id))
(let ((a1-6 (-> self root-override trans)))
(let ((s5-0 self))
(when (= a1-6 #t)
(if (and s5-0 (type-type? (-> s5-0 type) process-drawable) (nonzero? (-> s5-0 root-override)))
(set! a1-6 (-> s5-0 root-override trans))
(set! a1-6 (the-as vector #f))
)
)
)
(sound-trans-convert (-> gp-1 parms trans) a1-6)
)
(set! (-> gp-1 parms mask) (the-as uint 32))
(-> gp-1 id)
)
(if (and (-> self grab-player?) (< 0.2 (-> self path-pos)))
(set! (-> self grab-player?) (not (process-release? *target*)))
)
(none)
)
:code
(the-as (function none :behavior plat-button) anim-loop)
:post
(the-as (function none :behavior plat-button) rider-post)
)
(defstate plat-button-move-upward (plat-button)
:virtual #t
:event
(behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
(the-as object (when (or (= arg2 'touch) (= arg2 'attack))
(set! (-> self state-time) (-> *display* base-frame-counter))
#f
)
)
)
:enter
(behavior ()
(set! (-> self state-time) (-> *display* base-frame-counter))
(process-entity-status! self (entity-perm-status bit-3) #t)
(plat-button-camera-on)
(set-setting! *setting-control* self 'allow-look-around #f 0.0 0)
(none)
)
:exit
(behavior ()
(plat-button-camera-off)
(clear-pending-settings-from-process *setting-control* self 'allow-look-around)
(none)
)
:trans
(behavior ()
(if (= (-> self path-pos) 0.0)
(go-virtual plat-button-at-end)
)
(rider-trans)
(when (-> self go-back-if-lost-player?)
(when (or (not *target*) (and (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 4))
(not (and (logtest? (-> *target* control unknown-surface00 flags) 2048)
(zero? (logand (-> *target* control status) 1))
)
)
)
)
(set! (-> self go-back-if-lost-player?) #f)
(go-virtual plat-button-move-downward)
)
)
(let ((f0-4 (seek-with-smooth (-> self path-pos) 0.0 (* 0.1 (-> *display* seconds-per-frame)) 0.25 0.001)))
(set! (-> self path-pos) f0-4)
(let ((gp-0 (new 'stack-no-clear 'vector)))
(eval-path-curve! (-> self path) gp-0 f0-4 'interp)
(vector+! gp-0 gp-0 (-> self trans-off))
(move-to-point! (-> self root-override) gp-0)
)
)
(sound-play-by-name (static-sound-name "elev-loop") (-> self sound-id) 1024 0 0 1 #t)
(let ((gp-1 (the-as sound-rpc-set-param (get-sound-buffer-entry))))
(set! (-> gp-1 command) (sound-command set-param))
(set! (-> gp-1 id) (-> self sound-id))
(let ((a1-6 (-> self root-override trans)))
(let ((s5-0 self))
(when (= a1-6 #t)
(if (and s5-0 (type-type? (-> s5-0 type) process-drawable) (nonzero? (-> s5-0 root-override)))
(set! a1-6 (-> s5-0 root-override trans))
(set! a1-6 (the-as vector #f))
)
)
)
(sound-trans-convert (-> gp-1 parms trans) a1-6)
)
(set! (-> gp-1 parms mask) (the-as uint 32))
(-> gp-1 id)
)
(if (and (-> self grab-player?) (< (-> self path-pos) 0.8))
(set! (-> self grab-player?) (not (process-release? *target*)))
)
(none)
)
:code
(the-as (function none :behavior plat-button) anim-loop)
:post
(the-as (function none :behavior plat-button) rider-post)
)
(defstate plat-button-at-end (plat-button)
:virtual #t
:code
(behavior ()
(if (-> self allow-auto-kill)
(process-entity-status! self (entity-perm-status bit-3) #f)
)
(sound-stop (-> self sound-id))
(sound-play-by-name (static-sound-name "elev-land") (new-sound-id) 1024 0 0 1 #t)
(while #t
(if (or (not *target*)
(< 268435460.0 (vector-vector-xz-distance-squared (-> self root-override trans) (target-pos 0)))
)
(go-virtual plat-button-idle)
)
(suspend)
)
(none)
)
)
(defmethod TODO-RENAME-28 plat-button ((obj plat-button))
(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) default-collision-reaction)
(set! (-> s5-0 no-reaction)
(the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
)
(alloc-riders s5-0 1)
(let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 2) 0)))
(set! (-> s4-0 prim-core collide-as) (collide-kind ground-object))
(set! (-> s4-0 collide-with) (collide-kind target))
(set! (-> s4-0 prim-core action) (collide-action solid ca-1))
(set! (-> s4-0 transform-index) 0)
(set-vector! (-> s4-0 local-sphere) 0.0 -4096.0 0.0 27033.6)
(set-root-prim! s5-0 s4-0)
(let ((s3-0 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 0) (the-as uint 1))))
(set! (-> s3-0 prim-core collide-as) (collide-kind ground-object))
(set! (-> s3-0 collide-with) (collide-kind target))
(set! (-> s3-0 prim-core action) (collide-action solid ca-1))
(set! (-> s3-0 prim-core offense) (collide-offense indestructible))
(set! (-> s3-0 transform-index) 4)
(set-vector! (-> s3-0 local-sphere) 0.0 -3072.0 0.0 7372.8)
(append-prim s4-0 s3-0)
)
(let ((s3-1 (new 'process 'collide-shape-prim-mesh s5-0 (the-as uint 1) (the-as uint 2))))
(set! (-> s3-1 prim-core collide-as) (collide-kind ground-object))
(set! (-> s3-1 collide-with) (collide-kind target))
(set! (-> s3-1 prim-core action) (collide-action solid ca-1))
(set! (-> s3-1 prim-core offense) (collide-offense indestructible))
(set! (-> s3-1 transform-index) 3)
(set-vector! (-> s3-1 local-sphere) 0.0 -4096.0 0.0 27033.6)
(append-prim s4-0 s3-1)
)
)
(set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
(backup-collide-with-as s5-0)
(set! (-> obj root-override) s5-0)
s5-0
)
)
(defmethod can-target-move? plat-button ((obj plat-button))
0
(none)
)
(defmethod TODO-RENAME-27 plat-button ((obj plat-button))
(ja-channel-set! 1)
(cond
((can-activate? obj)
(let ((s5-0 (-> obj skel root-channel 0)))
(joint-control-channel-group-eval!
s5-0
(the-as art-joint-anim (-> obj draw art-group data 2))
num-func-identity
)
(set! (-> s5-0 frame-num) 0.0)
)
)
(else
(let ((s5-1 (-> obj skel root-channel 0)))
(joint-control-channel-group-eval!
s5-1
(the-as art-joint-anim (-> obj draw art-group data 2))
num-func-identity
)
(set! (-> s5-1 frame-num)
(the float (+ (-> (the-as art-joint-anim (-> obj draw art-group data 2)) data 0 length) -1))
)
)
)
)
(ja-post)
(update-transforms! (-> obj root-override))
(none)
)
(defmethod TODO-RENAME-31 plat-button ((obj plat-button))
(initialize-skeleton obj *plat-button-sg* '())
0
(none)
)
(defmethod TODO-RENAME-32 plat-button ((obj plat-button))
(go (method-of-object obj plat-button-idle))
0
(none)
)
(defmethod init-from-entity! plat-button ((obj plat-button) (arg0 entity-actor))
(set! (-> obj go-back-if-lost-player?) #f)
(set! (-> obj grab-player?) #f)
(set! (-> obj should-grab-player?) #f)
(set! (-> obj trans-off quad) (-> (the-as vector ((method-of-type res-lump get-property-struct)
arg0
'trans-offset
'interp
-1000000000.0
*null-vector*
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
quad
)
)
(set! (-> obj bidirectional?) (nonzero? (res-lump-value arg0 'bidirectional uint128)))
(TODO-RENAME-28 obj)
(process-drawable-from-entity! obj arg0)
(logclear! (-> obj mask) (process-mask actor-pause))
(TODO-RENAME-31 obj)
(logior! (-> obj skel status) (janim-status inited))
(set! (-> obj spawn-pos quad) (-> obj root-override trans quad))
(set! (-> obj path) (new 'process 'curve-control obj 'path -1000000000.0))
(logior! (-> obj path flags) (path-control-flag display draw-line draw-point draw-text))
(set! (-> obj path-pos) 0.0)
(let ((s5-1 (-> obj root-override trans)))
(eval-path-curve! (-> obj path) s5-1 (-> obj path-pos) 'interp)
(vector+! s5-1 s5-1 (-> obj trans-off))
)
(set! (-> obj sound-id) (new-sound-id))
(set! (-> obj allow-auto-kill) #t)
(can-target-move? obj)
(TODO-RENAME-27 obj)
(TODO-RENAME-32 obj)
(none)
)