jak-project/goal_src/levels/village1/assistant.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

397 lines
13 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: assistant.gc
;; name in dgo: assistant
;; dgos: L1, VI1
;; DECOMP BEGINS
(import "goal_src/import/assistant-ag.gc")
(deftype assistant (process-taskable)
((sound-id sound-id :offset-assert 380)
)
:heap-base #x110
:method-count-assert 53
:size-assert #x180
:flag-assert #x3501100180
)
(defskelgroup *assistant-sg* assistant assistant-lod0-jg assistant-idle-leaning-right-ja
((assistant-lod0-mg (meters 999999)))
:bounds (static-spherem 0 0 0 2)
:shadow assistant-shadow-mg
)
(defmethod dummy-52 assistant ((obj assistant))
(let ((v1-1 (-> obj draw shadow-ctrl)))
(when v1-1
(let ((f0-0 (-> obj root-override trans y)))
(let ((a0-2 v1-1))
(set! (-> a0-2 settings bot-plane w) (- (+ -4096.0 f0-0)))
)
0
(let ((a0-4 v1-1))
(set! (-> a0-4 settings top-plane w) (- (+ 4096.0 f0-0)))
)
)
0
(logclear! (-> v1-1 settings flags) (shadow-flags shdf03))
)
)
(none)
)
(defmethod draw-npc-shadow assistant ((obj assistant))
(-> obj draw shadow-ctrl)
(cond
((and (-> obj draw shadow)
(zero? (-> obj draw cur-lod))
(logtest? (-> obj draw status) (draw-status was-drawn))
)
(let ((v1-9 (-> obj draw shadow-ctrl)))
(logclear! (-> v1-9 settings flags) (shadow-flags disable-draw))
)
0
(update-direction-from-time-of-day (-> obj draw shadow-ctrl))
)
(else
(let ((v1-14 (-> obj draw shadow-ctrl)))
(logior! (-> v1-14 settings flags) (shadow-flags disable-draw))
)
0
)
)
(none)
)
(defmethod play-anim! assistant ((obj assistant) (arg0 symbol))
(case (current-status (-> obj tasks))
(((task-status need-hint) (task-status need-introduction))
(case (current-task (-> obj tasks))
(((game-task jungle-eggtop))
(when arg0
(let* ((s5-1 (-> obj tasks))
(s4-0 (method-of-object s5-1 save-reminder))
)
(s4-0 s5-1 (the int (the-as float (send-event *target* 'query 'pickup (pickup-type fuel-cell)))) 1)
)
(close-status! (-> obj tasks) (task-status need-introduction))
)
(new 'static 'spool-anim
:name "assistant-introduction-blue-eco-switch"
:index 10
:parts 11
:command-list '((0 want-levels village1 beach)
(128 joint "cameraB")
(312 joint "camera")
(492 joint "cameraB")
(537 joint "camera")
(734 display-level beach movie)
(734 want-force-vis beach #t)
(735 alive "ecovent-48")
(742 blackout 10)
(743 joint "cameraB")
(745 blackout 0)
(839 alive "ecovent-200")
(841 joint "camera")
(842 dead "ecovent-48")
(942 blackout 10)
(944 joint "cameraB")
(945 blackout 0)
(945 dead "ecovent-200")
(945 display-level beach #f)
(1049 blackout 10)
(1051 joint "camera")
(1052 blackout 0)
(1135 blackout 10)
(1137 joint "cameraB")
(1138 blackout 0)
(1216 joint "camera")
)
)
)
(else
(if arg0
(close-status! (-> obj tasks) (task-status need-introduction))
)
(new 'static 'spool-anim
:name "assistant-introduction-race-bike"
:index 12
:parts 6
:command-list '((0 want-levels village1 beach) (129 joint "cameraB") (319 joint "camera") (505 joint "cameraB"))
)
)
)
)
(((task-status need-reminder) (task-status need-reminder-a))
(set! (-> obj skippable) #t)
(cond
((= (current-task (-> obj tasks)) (game-task none))
(new 'static 'spool-anim :name "assistant-reminder-1-generic" :index 14 :parts 2 :command-list '())
)
((closed? (-> obj tasks) (game-task jungle-eggtop) (task-status need-resolution))
(new 'static 'spool-anim :name "assistant-reminder-1-race-bike" :index 13 :parts 3 :command-list '())
)
((or (closed? (-> obj tasks) (game-task misty-bike) (task-status need-resolution))
(not (closed? (-> obj tasks) (game-task misty-bike) (task-status need-introduction)))
)
(new 'static 'spool-anim :name "assistant-reminder-1-blue-eco-switch" :index 11 :parts 3 :command-list '())
)
((zero? (get-reminder (-> obj tasks) 2))
(if arg0
(save-reminder (-> obj tasks) 1 2)
)
(new 'static 'spool-anim :name "assistant-reminder-1-race-bike" :index 13 :parts 3 :command-list '())
)
(else
(if arg0
(save-reminder (-> obj tasks) 0 2)
)
(new 'static 'spool-anim :name "assistant-reminder-1-blue-eco-switch" :index 11 :parts 3 :command-list '())
)
)
)
(else
(if arg0
(format
0
"ERROR: <GMJ>: ~S playing anim for task status ~S~%"
(-> obj name)
(task-status->string (current-status (-> obj tasks)))
)
)
(-> obj draw art-group data 3)
)
)
)
(defmethod get-art-elem assistant ((obj assistant))
(-> obj draw art-group data 3)
)
(defmethod TODO-RENAME-43 assistant ((obj assistant))
(let ((s5-0 (TODO-RENAME-10 (-> obj ambient) (new 'stack-no-clear 'vector) (seconds 30) 122880.0 obj)))
(when s5-0
(let ((f0-2 (rand-float-gen)))
(cond
((< 16384.0 (-> s5-0 y))
#f
)
((< 0.8 f0-2)
(play-ambient (-> obj ambient) "ASSTLP01" #f (-> obj root-override trans))
)
((< 0.6 f0-2)
(play-ambient (-> obj ambient) "ASSTLP04" #f (-> obj root-override trans))
)
((< 0.4 f0-2)
(play-ambient (-> obj ambient) "ASSTLP05" #f (-> obj root-override trans))
)
((< 0.2 f0-2)
(play-ambient (-> obj ambient) "ASSTLP02" #f (-> obj root-override trans))
)
(else
(play-ambient (-> obj ambient) "ASSTLP03" #f (-> obj root-override trans))
)
)
)
)
)
)
(defstate idle (assistant)
:virtual #t
:code (behavior ()
(if (!= (ja-group) assistant-idle-leaning-right-ja)
(ja-channel-push! 1 (seconds 0.2))
)
(loop
(TODO-RENAME-43 self)
(ja :group! assistant-idle-leaning-right-ja)
(countdown (gp-0 (+ (the int (rand-float-gen)) 2))
(ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
(cond
((< (rand-float-gen) 0.66)
(ja-no-eval :group! assistant-idle-transition-to-welding-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
(sound-play "welding-loop" :id (-> self sound-id) :position (the-as symbol (target-pos 0)))
(ja :group! assistant-idle-welding-ja)
(let* ((f30-0 4.0)
(v1-76 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
(v1-77 (the-as number (logior #x3f800000 v1-76)))
)
(countdown (gp-2 (+ (the int (* f30-0 (+ -1.0 (the-as float v1-77)))) 4))
(ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(spawn (-> self part) (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data 30)))
(suspend)
(ja :num! (seek!))
)
(ja-no-eval :group! (ja-group) :num! (seek! 0.0) :frame-num max)
(until (ja-done? 0)
(spawn (-> self part) (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data 30)))
(suspend)
(ja :num! (seek! 0.0))
)
)
)
(sound-stop (-> self sound-id))
(ja-no-eval :group! assistant-idle-transition-to-welding-ja :num! (seek! 0.0) :frame-num max)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! 0.0))
)
(when (< (rand-float-gen) 0.66)
(ja-no-eval :group! assistant-idle-wiping-brow-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
)
(else
(ja-no-eval :group! assistant-idle-transition-right-to-left-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
(countdown (gp-3 (+ (the int (rand-float-gen)) 1))
(ja-no-eval :group! assistant-idle-leaning-left-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
(ja-no-eval :group! assistant-idle-transition-left-to-right-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
)
)
(none)
)
)
(defpartgroup group-assistant-torch
:id 122
:bounds (static-bspherem 0 0 0 15)
:parts ((sp-item 365 :fade-after (meters 30) :falloff-to (meters 30))
(sp-item 366 :fade-after (meters 60) :falloff-to (meters 80))
)
)
(defpart 365
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x12 :page #x2))
(sp-rnd-flt spt-num 0.1 1.0 1.0)
(sp-rnd-flt spt-scale-x (meters 1) (meters 3) 1.0)
(sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
(sp-copy-from-other spt-scale-y -4)
(sp-rnd-flt spt-r 100.0 28.0 1.0)
(sp-flt spt-g 100.0)
(sp-flt spt-b 80.0)
(sp-rnd-flt spt-a 32.0 64.0 1.0)
(sp-flt spt-fade-a -6.4)
(sp-int spt-timer 10)
(sp-cpuinfo-flags bit2 bit3)
)
)
(defpart 366
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
(sp-rnd-flt spt-num 0.1 1.0 1.0)
(sp-rnd-flt spt-scale-x (meters 0.1) (meters 0.1) 1.0)
(sp-copy-from-other spt-scale-y -4)
(sp-rnd-flt spt-r 128.0 128.0 1.0)
(sp-flt spt-g 128.0)
(sp-flt spt-b 64.0)
(sp-rnd-flt spt-a 32.0 96.0 1.0)
(sp-rnd-flt spt-vel-y (meters 0.013333334) (meters 0.08) 1.0)
(sp-flt spt-scalevel-x (meters -0.00016666666))
(sp-copy-from-other spt-scalevel-y -4)
(sp-flt spt-fade-g -0.2)
(sp-flt spt-fade-b -0.2)
(sp-flt spt-accel-y -8.192)
(sp-flt spt-friction 0.93)
(sp-int spt-timer 1200)
(sp-cpuinfo-flags bit2)
(sp-flt spt-userdata 140288.0)
(sp-func spt-func 'check-drop-level-assistant)
(sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 180.0) 1.0)
(sp-rnd-flt spt-conerot-y (degrees 45.0) (degrees 180.0) 1.0)
)
)
(defpart 367
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xf :page #x2))
(sp-rnd-flt spt-num 3.0 1.0 1.0)
(sp-rnd-flt spt-scale-x (meters 0.075) (meters 0.075) 1.0)
(sp-copy-from-other spt-scale-y -4)
(sp-rnd-flt spt-r 128.0 64.0 1.0)
(sp-flt spt-g 96.0)
(sp-rnd-flt spt-a 32.0 96.0 1.0)
(sp-rnd-flt spt-vel-y (meters 0.011666667) (meters 0.0033333334) 1.0)
(sp-flt spt-fade-a -0.85333335)
(sp-flt spt-accel-y -0.68266666)
(sp-int spt-timer 300)
(sp-cpuinfo-flags bit2)
(sp-rnd-flt spt-conerot-x (degrees 50.000004) (degrees 30.0) 1.0)
(sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
)
)
(defun check-drop-level-assistant ((arg0 sparticle-system) (arg1 sparticle-cpuinfo) (arg2 vector))
(when (< (-> arg2 y) (-> arg1 user-float))
(let ((gp-0 (new 'stack-no-clear 'vector)))
(sp-kill-particle arg0 arg1)
(if (< (rand-float-gen) 0.25)
(sound-play "water-drop")
)
(set-vector! gp-0 (-> arg2 x) (-> arg1 user-float) (-> arg2 z) 1.0)
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 367)
gp-0
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
)
)
(none)
)
(defmethod init-from-entity! assistant ((obj assistant) (arg0 entity-actor))
(dummy-40 obj arg0 *assistant-sg* 3 31 (new 'static 'vector :w 4096.0) 5)
(set! (-> obj bounce-away) #f)
(set! (-> obj part) (create-launch-control (-> *part-group-id-table* 122) obj))
(set! (-> obj tasks) (get-task-control (game-task jungle-eggtop)))
(set! (-> obj sound-id) (new-sound-id))
(set! (-> obj draw light-index) (the-as uint 1))
(case (get-task-status (game-task firecanyon-assistant))
(((task-status unknown))
(go (method-of-object obj idle))
)
(else
(cleanup-for-death obj)
(deactivate obj)
)
)
(none)
)