jak-project/goal_src/jak1/levels/village3/miners.gc
ManDude fe491c2b5e
[opengoal] make none a child of object (#3001)
Previously, `object` and `none` were both top-level types. This made
decompilation rather messy as they have no LCA and resulted in a lot of
variables coming out as type `none` which is very very wrong and
additionally there were plenty of casts to `object`. This changes it so
`none` becomes a child of `object` (it is still represented by
`NullType` which remains unusable in compilation).

This change makes `object` the sole top-level type, and the type that
can represent *any* GOAL object. I believe this matches the original
GOAL built-in type structure. A function that has a return type of
`object` can now return an integer or a `none` at the same time.
However, keep in mind that the return value of `(none)` is still
undefined, just as before. This also makes a cast to `object`
meaningless in 90% of the situations it showed up in (as every single
thing is already an `object`) and the decompiler will no longer emit
them. Casts to `none` are also reduced. Yay!

Additionally, state handlers also don't get the final `(none)` printed
out anymore. The return type of a state handler is completely
meaningless outside the event handler (which is return type `object`
anyway) so there are no limitations on what the last form needs to be. I
did this instead of making them return `object` to trick the decompiler
into not trying to output a variable to be used as a return value
(internally, in the decompiler they still have return type `none`, but
they have `object` elsewhere).

Fixes #1703 
Fixes #830 
Fixes #928
2023-09-22 10:54:49 +01:00

619 lines
20 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: miners.gc
;; name in dgo: miners
;; dgos: L1, VI3
(declare-type minershort process-taskable)
;; DECOMP BEGINS
(defbehavior miners-anim-loop minershort ()
(when (!= (ja-group) (get-art-elem self))
(ja-channel-push! 1 (seconds 0.2))
(ja :group! (get-art-elem self))
)
(loop
(suspend)
(ja :num! (loop! 2.0))
(if (= (-> self next-state name) 'idle)
(process-taskable-method-43 self)
)
)
(the-as none 0)
(none)
)
(deftype minertall (process-taskable)
()
:heap-base #x110
:method-count-assert 53
:size-assert #x17c
:flag-assert #x350110017c
)
(defskelgroup *minertall-sg* minertall minertall-lod0-jg minertall-idle-ja
((minertall-lod0-mg (meters 999999)))
:bounds (static-spherem 0 0 0 2.5)
:shadow minertall-shadow-mg
)
(defmethod process-taskable-method-52 minertall ((obj minertall))
(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 minertall ((obj minertall))
(-> 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! minertall ((obj minertall) (arg0 symbol))
(set! (-> obj talk-message) (text-id press-to-talk))
(current-status (-> obj tasks))
(if arg0
(format
0
"ERROR: <GMJ>: ~S playing anim for task status ~S~%"
(-> obj name)
(task-status->string (current-status (-> obj tasks)))
)
)
(the-as basic (-> obj draw art-group data 3))
)
(defmethod get-art-elem minertall ((obj minertall))
(-> obj draw art-group data 3)
)
(defstate idle (minertall)
:virtual #t
:trans (behavior ()
(set! (-> self will-talk) #f)
((-> (method-of-type process-taskable idle) trans))
)
:code (the-as (function none :behavior minertall) miners-anim-loop)
)
(defmethod init-from-entity! minertall ((obj minertall) (arg0 entity-actor))
(process-taskable-method-40 obj arg0 *minertall-sg* 32 47 (new 'static 'vector :w 4096.0) 5)
(set! (-> obj tasks) (get-task-control (game-task village3-miner-money1)))
(set! (-> obj draw light-index) (the-as uint 1))
(process-taskable-method-42 obj)
(none)
)
(deftype minershort (process-taskable)
((other-miner minertall :offset-assert 380)
)
:heap-base #x110
:method-count-assert 53
:size-assert #x180
:flag-assert #x3501100180
)
(defskelgroup *minershort-sg* minershort minershort-lod0-jg minershort-idle-ja
((minershort-lod0-mg (meters 999999)))
:bounds (static-spherem 0 0 0 2.5)
:shadow minershort-shadow-mg
)
(defpartgroup group-minershort-candle
:id 566
:bounds (static-bspherem 0 0 0 15)
:parts ((sp-item 2364 :fade-after (meters 60) :falloff-to (meters 60))
(sp-item 2365 :fade-after (meters 60) :falloff-to (meters 60))
(sp-item 2366 :fade-after (meters 60) :falloff-to (meters 60))
)
)
(defpart 2366
:init-specs ((:texture (new 'static 'texture-id :page #x2))
(:num 1.0 2.0)
(:y (meters 0))
(:scale-x (meters 0.075) (meters 0.075))
(:rot-z (degrees 0) (degrees 360))
(:scale-y :copy scale-x)
(:r 128.0 64.0)
(:g 128.0 32.0)
(:b 128.0 16.0)
(:a 32.0 32.0)
(:vel-y (meters 0) (meters 0.00033333333))
(:scalevel-x (meters 0.0005) (meters 0.001))
(:rotvel-z (degrees -0.2) (degrees 0.4))
(:scalevel-y :copy scalevel-x)
(:fade-r -0.32820514)
(:fade-g -0.32820514)
(:fade-b -0.32820514)
(:fade-a -0.16410257)
(:accel-y (meters 0.000033333334) (meters 0.00006666667))
(:timer (seconds 1.3))
(:flags (bit2 bit12 bit14))
(:conerot-x (degrees 0) (degrees 360))
(:conerot-y (degrees 0) (degrees 360))
(:conerot-radius (meters 0) (meters 0.05))
)
)
(defpart 2364
:init-specs ((:texture (new 'static 'texture-id :index #xf :page #x2))
(:num 3.0)
(:y (meters -0.08) (meters 0.02))
(:scale-x (meters 0.2) (meters 0.2))
(:scale-y :copy scale-x)
(:r 128.0 64.0)
(:g 64.0 64.0)
(:b 0.0 32.0)
(:a 32.0 32.0)
(:vel-x (meters 0) (meters 0.00016666666))
(:vel-z (meters 0) (meters 0.00016666666))
(:scalevel-x (meters -0.0016666667))
(:scalevel-y :copy scalevel-x)
(:fade-g -0.7111111)
(:accel-y (meters 0.00026666667) (meters 0.00006666667))
(:timer (seconds 0.2) (seconds 0.097))
(:flags (bit3))
)
)
(defpart 2365
:init-specs ((:texture (new 'static 'texture-id :index #x12 :page #x2))
(:num 1.0)
(:y (meters -0.02))
(:scale-x (meters 0.5) (meters 0.75))
(:rot-z (degrees 0) (degrees 360))
(:scale-y :copy scale-x)
(:r 128.0 64.0)
(:g 64.0 64.0)
(:b 0.0 32.0)
(:a 16.0 32.0)
(:vel-x (meters 0) (meters 0.00016666666))
(:vel-z (meters 0) (meters 0.00016666666))
(:scalevel-x (meters -0.0016666667))
(:scalevel-y :copy scalevel-x)
(:fade-g -0.7111111)
(:fade-a -1.92)
(:accel-y (meters 0.00026666667) (meters 0.00006666667))
(:timer (seconds 0.067))
(:flags (bit2 bit3))
)
)
(defmethod process-taskable-method-52 minershort ((obj minershort))
(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 minershort ((obj minershort))
(-> 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)
)
(defbehavior minershort-trans-hook minershort ()
(spawn (-> self part) (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data 14)))
(none)
)
(defmethod play-anim! minershort ((obj minershort) (arg0 symbol))
(set! (-> obj talk-message) (text-id press-to-talk))
(case (current-status (-> obj tasks))
(((task-status need-hint) (task-status need-introduction))
(if (not arg0)
(set! (-> obj will-talk) #t)
)
(case (current-task (-> obj tasks))
(((game-task village3-miner-money1))
(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)
)
(send-event (-> obj other-miner ppointer 3) 'clone (process->handle obj))
(close-specific-task! (game-task village3-miner-money1) (task-status need-introduction))
(close-specific-task! (game-task village3-miner-money2) (task-status need-introduction))
(close-specific-task! (game-task village3-miner-money3) (task-status need-introduction))
(close-specific-task! (game-task village3-miner-money4) (task-status need-introduction))
)
(new 'static 'spool-anim
:name "minershort-introduction-orbs"
:index 4
:parts 16
:command-list '((171 joint "cameraB")
(206 joint "camera")
(423 joint "cameraB")
(591 joint "camera")
(692 joint "cameraB")
(918 joint "camera")
(1122 joint "cameraB")
(1122 shadow self #f)
(1241 joint "camera")
(1241 shadow self #t)
)
)
)
(((game-task cave-gnawers))
(when arg0
(let* ((s5-2 (-> obj tasks))
(s4-1 (method-of-object s5-2 save-reminder))
)
(s4-1 s5-2 (the int (the-as float (send-event *target* 'query 'pickup (pickup-type fuel-cell)))) 1)
)
(send-event (-> obj other-miner ppointer 3) 'clone (process->handle obj))
(close-status! (-> obj tasks) (task-status need-introduction))
)
(new 'static 'spool-anim
:name "minershort-introduction-gnawers"
:index 9
:parts 8
:command-list '((0 want-levels village3 maincave)
(149 joint "cameraB")
(158 display-level maincave movie)
(158 want-force-vis maincave #t)
(435 display-level maincave #f)
(435 joint "camera")
(680 joint "cameraB")
(719 joint "camera")
)
)
)
(else
(when arg0
(send-event (-> obj other-miner ppointer 3) 'clone (process->handle obj))
(close-status! (-> obj tasks) (task-status need-introduction))
)
(new 'static 'spool-anim
:name "minershort-introduction-switch"
:index 11
:parts 7
:command-list '((2 shadow "minertall-1" #f) (835 shadow "minertall-1" #t))
)
)
)
)
(((task-status need-reminder))
(set! (-> obj skippable) #t)
(let ((s4-2 (+ (get-reminder (-> obj tasks) 0) 1)))
(if (< (the-as uint 3) (the-as uint s4-2))
(set! s4-2 0)
)
(countdown (s3-0 4)
(let ((v1-59 s4-2))
(cond
((zero? v1-59)
(if (not (or (= (get-task-status (game-task village3-miner-money1)) (task-status need-reminder))
(= (get-task-status (game-task village3-miner-money2)) (task-status need-reminder))
(= (get-task-status (game-task village3-miner-money3)) (task-status need-reminder))
(= (get-task-status (game-task village3-miner-money4)) (task-status need-reminder))
)
)
(set! s4-2 1)
)
)
((= v1-59 1)
(if (!= (get-task-status (game-task cave-gnawers)) (task-status need-reminder))
(set! s4-2 2)
)
)
((= v1-59 2)
(if (not (or (= (get-task-status (game-task village3-miner-money1)) (task-status need-reminder))
(= (get-task-status (game-task village3-miner-money2)) (task-status need-reminder))
(= (get-task-status (game-task village3-miner-money3)) (task-status need-reminder))
(= (get-task-status (game-task village3-miner-money4)) (task-status need-reminder))
)
)
(set! s4-2 3)
)
)
(else
(if (!= (get-task-status (game-task snow-eggtop)) (task-status need-reminder))
(set! s4-2 0)
)
)
)
)
)
(if arg0
(save-reminder (-> obj tasks) s4-2 0)
)
(cond
((zero? s4-2)
(new 'static 'spool-anim :name "minershort-reminder-1-orbs" :index 5 :parts 3 :command-list '())
)
((= s4-2 1)
(if arg0
(send-event (-> obj other-miner ppointer 3) 'clone (process->handle obj))
)
(new 'static 'spool-anim :name "minershort-reminder-1-gnawers" :index 10 :parts 3 :command-list '())
)
((= s4-2 2)
(if arg0
(send-event (-> obj other-miner ppointer 3) 'clone (process->handle obj))
)
(new 'static 'spool-anim :name "minershort-reminder-2-orbs" :index 6 :parts 2 :command-list '())
)
(else
(if arg0
(send-event (-> obj other-miner ppointer 3) 'clone (process->handle obj))
)
(new 'static 'spool-anim
:name "minershort-reminder-1-switch"
:index 12
:parts 5
:command-list '((2 shadow "minertall-1" #f) (500 shadow "minertall-1" #t))
)
)
)
)
)
(((task-status need-reward-speech))
(let ((s4-3 (get-reminder (-> obj tasks) 2)))
(cond
(arg0
(send-event (-> obj other-miner ppointer 3) 'clone (process->handle obj))
(set! (-> obj cell-for-task) (current-task (-> obj tasks)))
(close-current! (-> obj tasks))
(send-event *target* 'get-pickup 5 (- (-> *GAME-bank* money-task-inc)))
(save-reminder (-> obj tasks) (+ s4-3 1) 2)
)
(else
(set! (-> obj will-talk) #t)
(set! (-> obj talk-message) (text-id press-to-trade-money))
)
)
(if (< (the-as uint s4-3) (the-as uint 3))
(new 'static 'spool-anim :name "minershort-resolution-1-orbs" :index 7 :parts 2 :command-list '())
(new 'static 'spool-anim
:name "minershort-resolution-2-orbs"
:index 8
:parts 6
:command-list '((154 joint "cameraB") (461 joint "camera"))
)
)
)
)
(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)
)
)
)
(defstate play-anim (minershort)
:virtual #t
:exit (behavior ()
(send-event (-> self other-miner ppointer 3) 'end-mode)
((-> (method-of-type process-taskable play-anim) exit))
)
)
(defmethod get-art-elem minershort ((obj minershort))
(-> obj draw art-group data 3)
)
(defmethod process-taskable-method-43 minershort ((obj minershort))
(when (ambient-control-method-10 (-> obj ambient) (new 'stack-no-clear 'vector) (seconds 30) 122880.0 obj)
(let ((f0-2 (rand-float-gen)))
(cond
((< 0.9655172 f0-2)
(play-ambient (-> obj ambient) "MIN-LO01" #f (-> obj root-override trans))
)
((< 0.9310345 f0-2)
(play-ambient (-> obj ambient) "MIN-LO03" #f (-> obj root-override trans))
)
((< 0.8965517 f0-2)
(play-ambient (-> obj ambient) "MIN-LO04" #f (-> obj root-override trans))
)
((< 0.86206895 f0-2)
(play-ambient (-> obj ambient) "MIN-LO05" #f (-> obj root-override trans))
)
((< 0.82758623 f0-2)
(play-ambient (-> obj ambient) "MIN-LO06" #f (-> obj root-override trans))
)
((< 0.79310346 f0-2)
(play-ambient (-> obj ambient) "MSH-AM01" #f (-> obj root-override trans))
)
((< 0.7586207 f0-2)
(play-ambient (-> obj ambient) "MSH-AM02" #f (-> obj root-override trans))
)
((< 0.7241379 f0-2)
(play-ambient (-> obj ambient) "MSH-AM03" #f (-> obj root-override trans))
)
((< 0.6896552 f0-2)
(play-ambient (-> obj ambient) "MSH-AM04" #f (-> obj root-override trans))
)
((< 0.6551724 f0-2)
(play-ambient (-> obj ambient) "MSH-AM05" #f (-> obj root-override trans))
)
((< 0.62068963 f0-2)
(play-ambient (-> obj ambient) "MSH-AM06" #f (-> obj root-override trans))
)
((< 0.5862069 f0-2)
(play-ambient (-> obj ambient) "MSH-AM07" #f (-> obj root-override trans))
)
((< 0.55172414 f0-2)
(play-ambient (-> obj ambient) "MSH-AM08" #f (-> obj root-override trans))
)
((< 0.51724136 f0-2)
(play-ambient (-> obj ambient) "MSH-AM09" #f (-> obj root-override trans))
)
((< 0.4827586 f0-2)
(play-ambient (-> obj ambient) "MSH-AM10" #f (-> obj root-override trans))
)
((< 0.44827586 f0-2)
(play-ambient (-> obj ambient) "MSH-AM11" #f (-> obj root-override trans))
)
((< 0.41379312 f0-2)
(play-ambient (-> obj ambient) "MSH-AM12" #f (-> obj root-override trans))
)
((< 0.37931034 f0-2)
(play-ambient (-> obj ambient) "MSH-AM1A" #f (-> obj root-override trans))
)
((< 0.3448276 f0-2)
(play-ambient (-> obj ambient) "MSH-AM2A" #f (-> obj root-override trans))
)
((< 0.31034482 f0-2)
(play-ambient (-> obj ambient) "MSH-AM3A" #f (-> obj root-override trans))
)
((< 0.27586207 f0-2)
(play-ambient (-> obj ambient) "MTA-AM01" #f (-> obj root-override trans))
)
((< 0.2413793 f0-2)
(play-ambient (-> obj ambient) "MTA-AM02" #f (-> obj root-override trans))
)
((< 0.20689656 f0-2)
(play-ambient (-> obj ambient) "MTA-AM03" #f (-> obj root-override trans))
)
((< 0.1724138 f0-2)
(play-ambient (-> obj ambient) "MTA-AM04" #f (-> obj root-override trans))
)
((< 0.13793103 f0-2)
(play-ambient (-> obj ambient) "MTA-AM05" #f (-> obj root-override trans))
)
((< 0.10344828 f0-2)
(play-ambient (-> obj ambient) "MTA-AM06" #f (-> obj root-override trans))
)
((< 0.06896552 f0-2)
(play-ambient (-> obj ambient) "MTA-AM07" #f (-> obj root-override trans))
)
((< 0.03448276 f0-2)
(play-ambient (-> obj ambient) "MTA-AM08" #f (-> obj root-override trans))
)
(else
(play-ambient (-> obj ambient) "MTA-AM09" #f (-> obj root-override trans))
)
)
)
)
)
(defstate idle (minershort)
:virtual #t
:code miners-anim-loop
)
(defmethod init-from-entity! minershort ((obj minershort) (arg0 entity-actor))
(process-taskable-method-40 obj arg0 *minershort-sg* 34 46 (new 'static 'vector :w 4096.0) 5)
(set! (-> obj part) (create-launch-control (-> *part-group-id-table* 566) obj))
(set! (-> obj tasks) (get-task-control (game-task village3-miner-money1)))
(set! (-> obj other-miner) (the-as minertall (entity-actor-lookup arg0 'alt-actor 0)))
(set! (-> obj cur-trans-hook) minershort-trans-hook)
(set! (-> obj sound-flava) (music-flava miners))
(set! (-> obj draw light-index) (the-as uint 1))
(process-taskable-method-42 obj)
(none)
)
(deftype cavegem (process-drawable)
()
:heap-base #x40
:method-count-assert 21
:size-assert #xb0
:flag-assert #x15004000b0
(:methods
(idle () _type_ :state 20)
)
)
(defskelgroup *cavegem-sg* cavegem cavegem-lod0-jg cavegem-idle-ja
((cavegem-lod0-mg (meters 999999)))
:bounds (static-spherem 0 0 0 9)
)
(defstate idle (cavegem)
:virtual #t
:code (behavior ()
(loop
(ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
)
:post (the-as (function none :behavior cavegem) ja-post)
)
(defmethod init-from-entity! cavegem ((obj cavegem) (arg0 entity-actor))
(set! (-> obj root) (new 'process 'trsqv))
(process-drawable-from-entity! obj arg0)
(initialize-skeleton obj *cavegem-sg* '())
(go (method-of-object obj idle))
(none)
)