jak-project/goal_src/levels/common/plat-eco.gc
ManDude 8ccb1dfb66
[decomp] macros for sound playback (#1453)
* `sound-play` macro

* update source

* fix `add-debug-light` lol

* fix `add-debug-light` forreal

* Update debug.gc

* update some mood/tod decomp
2022-06-13 18:39:22 -04:00

309 lines
11 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: plat-eco.gc
;; name in dgo: plat-eco
;; dgos: GAME, COMMON, L1
;; DECOMP BEGINS
(import "goal_src/import/plat-eco-ag.gc")
(deftype plat-eco (plat)
((notice-dist float :offset-assert 264)
(sync-offset-dest float :offset-assert 268)
(sync-offset-faux float :offset-assert 272)
(sync-linear-val float :offset-assert 276)
(target handle :offset-assert 280)
(unlit-look lod-set :inline :offset-assert 288)
(lit-look lod-set :inline :offset-assert 324)
)
:heap-base #x100
:method-count-assert 33
:size-assert #x165
:flag-assert #x2101000165
(:methods
(notice-blue (handle) _type_ :replace :state 29)
)
)
(defskelgroup *plat-eco-unlit-sg* plat-eco plat-eco-lod0-jg plat-eco-idle-ja
((plat-eco-lod0-mg (meters 20)) (plat-eco-lod1-mg (meters 40)) (plat-eco-lod2-mg (meters 999999)))
:bounds (static-spherem 0 0 0 3)
)
(defskelgroup *plat-eco-lit-sg* plat-eco plat-eco-lod0-jg plat-eco-idle-ja
((plat-eco-lit-lod0-mg (meters 20)) (plat-eco-lit-lod1-mg (meters 40)) (plat-eco-lit-lod2-mg (meters 999999)))
:bounds (static-spherem 0 0 0 3)
)
(defstate plat-idle (plat-eco)
:virtual #t
:event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
(case arg2
(('wake)
(go-virtual plat-path-active (the-as plat #f))
)
(('eco-blue)
(go-virtual notice-blue (process->handle arg0))
)
(('ridden 'edge-grabbed)
(when (send-event *target* 'query 'powerup (pickup-type eco-blue))
(send-to-all (-> self link) 'wake)
(go-virtual plat-path-active (the-as plat #f))
)
)
)
)
:enter (behavior ()
(lods-assign! (-> self draw) (-> self unlit-look))
(none)
)
:trans (behavior ()
(when (and (and *target*
(>= (-> self notice-dist) (vector-vector-distance (-> self root-override trans) (-> *target* control trans)))
)
(send-event *target* 'query 'powerup (pickup-type eco-blue))
)
(send-to-all (-> self link) 'wake)
(go-virtual plat-path-active (the-as plat #f))
)
(if (and *target*
(>= (-> self notice-dist) (vector-vector-distance (-> self root-override trans) (-> *target* control trans)))
)
(level-hint-spawn
(game-text-id daxter-blue-eco-plat-tutorial)
"sksp0073"
(the-as entity #f)
*entity-pool*
(game-task none)
)
)
(none)
)
:code (behavior ()
(ja-post)
(update-transforms! (-> self root-override))
(anim-loop)
(none)
)
:post (the-as (function none :behavior plat-eco) ja-post)
)
(defstate notice-blue (plat-eco)
:virtual override
:event (behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
(case arg2
(('wake)
(sound-play "blue-eco-on" :position (the-as symbol (-> self root-override trans)))
(go-virtual plat-path-active (the-as plat #f))
)
(('ridden 'edge-grabbed)
(when (send-event *target* 'query 'powerup (pickup-type eco-blue))
(send-to-all (-> self link) 'wake)
(go-virtual plat-path-active (the-as plat #f))
)
)
)
)
:trans (behavior ()
((-> (method-of-object self plat-idle) trans))
(let ((a1-0 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-0 from) self)
(set! (-> a1-0 num-params) 2)
(set! (-> a1-0 message) 'query)
(set! (-> a1-0 param 0) (the-as uint 'powerup))
(set! (-> a1-0 param 1) (the-as uint 3))
(if (and (not (send-event-function *target* a1-0))
(begin (logior! (-> self mask) (process-mask sleep-code)) (not (-> self bouncing)))
)
(go-virtual plat-idle)
)
)
(none)
)
:code (behavior ((arg0 handle))
(set! (-> self target) arg0)
(loop
(let* ((gp-0 (handle->process (-> self target)))
(v1-4 (if (and (nonzero? gp-0) (type-type? (-> gp-0 type) process-drawable))
gp-0
)
)
)
(when v1-4
(let* ((gp-1 (-> (the-as process-drawable v1-4) root))
(v1-6 (if (and (nonzero? gp-1) (type-type? (-> gp-1 type) collide-shape))
gp-1
)
)
)
(when v1-6
(let* ((s5-0 (-> self root-override root-prim prim-core))
(a1-3 (-> (the-as collide-shape v1-6) root-prim prim-core))
(f30-0 (vector-vector-distance (the-as vector s5-0) (the-as vector a1-3)))
)
(when (rand-vu-percent? 0.5)
(let ((gp-2 (new 'stack-no-clear 'vector)))
(set! (-> gp-2 quad) (-> s5-0 world-sphere quad))
(dotimes (s5-1 3)
(+! (-> gp-2 data s5-1) (rand-vu-float-range -5324.8 5324.8))
)
(eco-blue-glow gp-2)
)
)
(set! (-> self bouncing) #t)
(activate!
(-> self smush)
(lerp-scale
(rand-vu-float-range 1.1 1.3)
(rand-vu-float-range 1.0 1.02)
f30-0
(-> *FACT-bank* suck-suck-dist)
(-> *FACT-bank* suck-bounce-dist)
)
60
60
1.0
1.0
)
)
)
)
)
)
(suspend)
)
(none)
)
:post (behavior ()
(plat-trans)
(plat-post)
(none)
)
)
(defstate plat-path-active (plat-eco)
:virtual #t
:enter (behavior ((arg0 plat))
(lods-assign! (-> self draw) (-> self lit-look))
(sync-now! (-> self sync) (-> self sync-linear-val))
(set! (-> self sync-offset-faux) (-> self sync offset))
(let* ((f0-3 (the float (-> self sync period)))
(f1-1 (* 0.5 f0-3))
)
(if (< f1-1 (- (-> self sync-offset-dest) (-> self sync-offset-faux)))
(+! (-> self sync-offset-faux) f0-3)
)
(if (< f1-1 (- (-> self sync-offset-faux) (-> self sync-offset-dest)))
(set! (-> self sync-offset-faux) (- (-> self sync-offset-faux) f0-3))
)
)
(cond
(arg0
(let ((f0-5 (-> self sync-offset-dest)))
(set! (-> self sync offset) f0-5)
(set! (-> self sync-offset-faux) f0-5)
)
)
(else
(process-entity-status! self (entity-perm-status complete) #t)
(dotimes (gp-1 5)
(spawn-projectile-blue *target*)
)
)
)
(none)
)
:trans (behavior ()
(when (!= (-> self sync-offset-faux) (-> self sync-offset-dest))
(seek! (-> self sync-offset-faux) (-> self sync-offset-dest) (* 12.0 (-> *display* seconds-per-frame)))
(let* ((f0-7 (the float (-> self sync period)))
(f1-3 (+ (-> self sync-offset-faux) f0-7))
)
(set! (-> self sync offset) (- f1-3 (* (the float (the int (/ f1-3 f0-7))) f0-7)))
)
)
((-> (method-of-type plat plat-path-active) trans))
(none)
)
)
(defmethod dummy-24 plat-eco ((obj plat-eco))
(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-mesh s5-0 (the-as uint 0) (the-as uint 0))))
(set! (-> s4-0 prim-core collide-as) (collide-kind ground-object blue-eco-suck))
(set! (-> s4-0 collide-with) (collide-kind target))
(set! (-> s4-0 prim-core action) (collide-action solid ca-1))
(set! (-> s4-0 prim-core offense) (collide-offense indestructible))
(set! (-> s4-0 transform-index) 0)
(set-vector! (-> s4-0 local-sphere) 0.0 -1228.8 0.0 13926.4)
(set-root-prim! s5-0 s4-0)
)
(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)
)
0
(none)
)
(defmethod get-unlit-skel plat-eco ((obj plat-eco))
*plat-eco-unlit-sg*
)
(defmethod get-lit-skel plat-eco ((obj plat-eco))
*plat-eco-lit-sg*
)
(defmethod init-from-entity! plat-eco ((obj plat-eco) (arg0 entity-actor))
(set! (-> obj mask) (logior (process-mask platform) (-> obj mask)))
(set! (-> obj notice-dist) (res-lump-float arg0 'notice-dist :default -1.0))
(set! (-> obj link) (new 'process 'actor-link-info obj))
(dummy-24 obj)
(process-drawable-from-entity! obj arg0)
(let ((s4-0 (get-unlit-skel obj))
(s5-1 (get-lit-skel obj))
)
(initialize-skeleton obj s4-0 '())
(setup-lods! (-> obj unlit-look) s4-0 (-> obj draw art-group) (-> obj entity))
(setup-lods! (-> obj lit-look) s5-1 (-> obj draw art-group) (-> obj entity))
)
(logclear! (-> obj mask) (process-mask actor-pause))
(update-transforms! (-> obj root-override))
(set! (-> obj part) (create-launch-control (-> *part-group-id-table* 107) obj))
(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 fact)
(new 'process 'fact-info obj (pickup-type eco-pill-random) (-> *FACT-bank* default-pill-inc))
)
(load-params! (-> obj sync) obj (the-as uint 3000) 0.0 0.15 0.15)
(set! (-> obj sync-offset-dest) (-> obj sync offset))
(set! (-> obj sync-linear-val) (get-phase-offset (-> obj sync)))
(sync-now! (-> obj sync) (-> obj sync-linear-val))
(set! (-> obj sync-offset-faux) (-> obj sync offset))
(set! (-> obj path-pos) (get-current-phase-with-mirror (-> obj sync)))
(eval-path-curve! (-> obj path) (-> obj root-override trans) (-> obj path-pos) 'interp)
(set! (-> obj sound-id) (new-sound-id))
(dummy-26 obj)
(dummy-21 obj)
(if (or (and (-> obj entity) (logtest? (-> obj entity extra perm status) (entity-perm-status complete)))
(< (-> obj notice-dist) 0.0)
)
(go (method-of-object obj plat-path-active) (the-as plat #t))
(go (method-of-object obj plat-idle))
)
(none)
)