mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
cd68cb671e
Major change to how `deftype` shows up in our code: - the decompiler will no longer emit the `offset-assert`, `method-count-assert`, `size-assert` and `flag-assert` parameters. There are extremely few cases where having this in the decompiled code is helpful, as the types there come from `all-types` which already has those parameters. This also doesn't break type consistency because: - the asserts aren't compared. - the first step of the test uses `all-types`, which has the asserts, which will throw an error if they're bad. - the decompiler won't emit the `heap-base` parameter unless necessary now. - the decompiler will try its hardest to turn a fixed-offset field into an `overlay-at` field. It falls back to the old offset if all else fails. - `overlay-at` now supports field "dereferencing" to specify the offset that's within a field that's a structure, e.g.: ```lisp (deftype foobar (structure) ((vec vector :inline) (flags int32 :overlay-at (-> vec w)) ) ) ``` in this structure, the offset of `flags` will be 12 because that is the final offset of `vec`'s `w` field within this structure. - **removed ID from all method declarations.** IDs are only ever automatically assigned now. Fixes #3068. - added an `:overlay` parameter to method declarations, in order to declare a new method that goes on top of a previously-defined method. Syntax is `:overlay <method-name>`. Please do not ever use this. - added `state-methods` list parameter. This lets you quickly specify a list of states to be put in the method table. Same syntax as the `states` list parameter. The decompiler will try to put as many states in this as it can without messing with the method ID order. Also changes `defmethod` to make the first type definition (before the arguments) optional. The type can now be inferred from the first argument. Fixes #3093. --------- Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
263 lines
8.9 KiB
Common Lisp
263 lines
8.9 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: nest-obs.gc
|
|
;; name in dgo: nest-obs
|
|
;; dgos: NESTT, NES
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype nest-switch (process-drawable)
|
|
((set-camera symbol)
|
|
(notify-actor entity-actor)
|
|
(y-start float)
|
|
(y-delta float)
|
|
(y-rot-rate float)
|
|
)
|
|
(:state-methods
|
|
up
|
|
down
|
|
)
|
|
)
|
|
|
|
|
|
(defskelgroup skel-nest-switch cas-switch cas-switch-lod0-jg cas-switch-idle-ja
|
|
((cas-switch-lod0-mg (meters 999999)))
|
|
:bounds (static-spherem 0 2 0 3.5)
|
|
:origin-joint-index 3
|
|
)
|
|
|
|
(defstate up (nest-switch)
|
|
:virtual #t
|
|
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
|
|
(case message
|
|
(('attack)
|
|
(let ((v1-1 (the-as attack-info (-> block param 1))))
|
|
(when (or (= (-> v1-1 mode) 'spin) (= (-> v1-1 mode) 'spin-air))
|
|
(let ((a1-3 (new 'stack-no-clear 'event-message-block)))
|
|
(set! (-> a1-3 from) (process->ppointer self))
|
|
(set! (-> a1-3 num-params) 0)
|
|
(set! (-> a1-3 message) 'trigger)
|
|
(let ((t9-0 send-event-function)
|
|
(v1-6 (-> self notify-actor))
|
|
)
|
|
(t9-0
|
|
(if v1-6
|
|
(-> v1-6 extra process)
|
|
)
|
|
a1-3
|
|
)
|
|
)
|
|
)
|
|
(go-virtual down)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
:trans rider-trans
|
|
:code sleep-code
|
|
:post rider-post
|
|
)
|
|
|
|
(defstate down (nest-switch)
|
|
:virtual #t
|
|
:enter (behavior ()
|
|
(set-time! (-> self state-time))
|
|
(set! (-> self set-camera) #f)
|
|
)
|
|
:trans (behavior ()
|
|
(when (and (not (-> self set-camera)) (time-elapsed? (-> self state-time) (seconds 0.6)))
|
|
(process-grab? *target* #f)
|
|
(hide-hud-quick #f)
|
|
(set-setting! 'process-mask 'set 0.0 (process-mask movie enemy))
|
|
(set-setting! 'entity-name "camera-253" 0.0 0)
|
|
(set! (-> self set-camera) #t)
|
|
)
|
|
(rider-trans)
|
|
)
|
|
:code (behavior ()
|
|
(set! (-> self y-rot-rate) 0.0)
|
|
(logclear! (-> self mask) (process-mask actor-pause))
|
|
(while (< 0.0 (-> self y-delta))
|
|
(seek! (-> self y-rot-rate) 500.0 (* 1000.0 (seconds-per-frame)))
|
|
(quaternion-rotate-y!
|
|
(-> self root quat)
|
|
(-> self root quat)
|
|
(* 182.04445 (seconds-per-frame) (-> self y-rot-rate))
|
|
)
|
|
(seek! (-> self y-delta) 0.0 (* 4096.0 (seconds-per-frame) (* 0.006 (-> self y-rot-rate))))
|
|
(set! (-> self root trans y) (+ (-> self y-start) (-> self y-delta)))
|
|
(suspend)
|
|
)
|
|
(let ((gp-0 (current-time)))
|
|
(until (time-elapsed? gp-0 (seconds 1))
|
|
(seek! (-> self y-rot-rate) 0.0 (* 4000.0 (seconds-per-frame)))
|
|
(quaternion-rotate-y!
|
|
(-> self root quat)
|
|
(-> self root quat)
|
|
(* 182.04445 (seconds-per-frame) (-> self y-rot-rate))
|
|
)
|
|
(suspend)
|
|
)
|
|
)
|
|
(let ((gp-1 (current-time)))
|
|
(until (time-elapsed? gp-1 (seconds 1))
|
|
(suspend)
|
|
)
|
|
)
|
|
(remove-setting! 'entity-name)
|
|
(remove-setting! 'process-mask)
|
|
(process-release? *target*)
|
|
(logior! (-> self mask) (process-mask actor-pause))
|
|
(sleep-code)
|
|
)
|
|
:post rider-post
|
|
)
|
|
|
|
;; WARN: Return type mismatch object vs none.
|
|
(defmethod init-from-entity! ((this nest-switch) (arg0 entity-actor))
|
|
"Typically the method that does the initial setup on the process, potentially using the [[entity-actor]] provided as part of that.
|
|
This commonly includes things such as:
|
|
- stack size
|
|
- collision information
|
|
- loading the skeleton group / bones
|
|
- sounds"
|
|
(let ((s4-0 (new 'process 'collide-shape this (collide-list-enum usually-hit-by-player))))
|
|
(let ((s3-0 (new 'process 'collide-shape-prim-group s4-0 (the-as uint 3) 0)))
|
|
(set! (-> s4-0 total-prims) (the-as uint 4))
|
|
(set! (-> s3-0 prim-core collide-as) (collide-spec obstacle))
|
|
(set! (-> s3-0 prim-core collide-with) (collide-spec jak hit-by-others-list player-list))
|
|
(set! (-> s3-0 prim-core action) (collide-action solid no-standon))
|
|
(set-vector! (-> s3-0 local-sphere) 0.0 4096.0 0.0 20480.0)
|
|
(set! (-> s4-0 root-prim) s3-0)
|
|
)
|
|
(let ((v1-8 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint 0) (the-as uint 0))))
|
|
(set! (-> v1-8 prim-core collide-as) (collide-spec obstacle))
|
|
(set! (-> v1-8 prim-core collide-with) (collide-spec jak hit-by-others-list player-list))
|
|
(set! (-> v1-8 prim-core action) (collide-action solid))
|
|
(set! (-> v1-8 transform-index) 3)
|
|
(set-vector! (-> v1-8 local-sphere) 0.0 8192.0 0.0 14336.0)
|
|
)
|
|
(let ((v1-10 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint 1) (the-as uint 1))))
|
|
(set! (-> v1-10 prim-core collide-as) (collide-spec obstacle))
|
|
(set! (-> v1-10 prim-core collide-with) (collide-spec jak hit-by-others-list player-list))
|
|
(set! (-> v1-10 prim-core action) (collide-action solid rideable))
|
|
(set! (-> v1-10 transform-index) 3)
|
|
(set-vector! (-> v1-10 local-sphere) 0.0 8192.0 0.0 14336.0)
|
|
)
|
|
(let ((v1-12 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
|
|
(set! (-> v1-12 prim-core collide-as) (collide-spec obstacle))
|
|
(set! (-> v1-12 prim-core action) (collide-action solid no-standon))
|
|
(set! (-> v1-12 transform-index) 3)
|
|
(set-vector! (-> v1-12 local-sphere) 0.0 8192.0 0.0 8192.0)
|
|
)
|
|
(set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
|
|
(let ((v1-15 (-> s4-0 root-prim)))
|
|
(set! (-> s4-0 backup-collide-as) (-> v1-15 prim-core collide-as))
|
|
(set! (-> s4-0 backup-collide-with) (-> v1-15 prim-core collide-with))
|
|
)
|
|
(set! (-> this root) s4-0)
|
|
)
|
|
(process-drawable-from-entity! this arg0)
|
|
(initialize-skeleton
|
|
this
|
|
(the-as skeleton-group (art-group-get-by-name *level* "skel-nest-switch" (the-as (pointer uint32) #f)))
|
|
(the-as pair 0)
|
|
)
|
|
(set! (-> this notify-actor) (entity-actor-lookup arg0 'alt-actor 0))
|
|
(set! (-> this y-start) (+ -12288.0 (-> this root trans y)))
|
|
(set! (-> this y-delta) 12288.0)
|
|
(go (method-of-object this up))
|
|
(none)
|
|
)
|
|
|
|
(deftype nest-piston (process-drawable)
|
|
((y-level float)
|
|
(y-offset float)
|
|
)
|
|
(:state-methods
|
|
idle
|
|
up
|
|
)
|
|
)
|
|
|
|
|
|
(defskelgroup skel-nest-piston piston piston-lod0-jg piston-idle-ja
|
|
((piston-lod0-mg (meters 999999)))
|
|
:bounds (static-spherem 0 0 0 4)
|
|
)
|
|
|
|
(defstate idle (nest-piston)
|
|
:virtual #t
|
|
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
|
|
(case message
|
|
(('trigger)
|
|
(go-virtual up)
|
|
)
|
|
)
|
|
)
|
|
:code sleep-code
|
|
)
|
|
|
|
(defstate up (nest-piston)
|
|
:virtual #t
|
|
:trans rider-trans
|
|
:code (behavior ()
|
|
(let ((gp-0 (current-time)))
|
|
(until (time-elapsed? gp-0 (seconds 1))
|
|
(suspend)
|
|
)
|
|
)
|
|
(while (< (-> self y-offset) 16384.0)
|
|
(seek! (-> self y-offset) 16384.0 (* 8192.0 (seconds-per-frame)))
|
|
(set! (-> self root trans y) (+ (-> self y-level) (-> self y-offset)))
|
|
(suspend)
|
|
)
|
|
(logior! (-> self mask) (process-mask actor-pause))
|
|
(sleep-code)
|
|
)
|
|
:post rider-post
|
|
)
|
|
|
|
;; WARN: Return type mismatch object vs none.
|
|
(defmethod init-from-entity! ((this nest-piston) (arg0 entity-actor))
|
|
"Typically the method that does the initial setup on the process, potentially using the [[entity-actor]] provided as part of that.
|
|
This commonly includes things such as:
|
|
- stack size
|
|
- collision information
|
|
- loading the skeleton group / bones
|
|
- sounds"
|
|
(let ((s4-0 (new 'process 'collide-shape this (collide-list-enum usually-hit-by-player))))
|
|
(let ((s3-0 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint 0) (the-as uint 0))))
|
|
(set! (-> s3-0 prim-core collide-as) (collide-spec obstacle pusher))
|
|
(set! (-> s3-0 prim-core collide-with) (collide-spec jak bot player-list))
|
|
(set! (-> s3-0 prim-core action) (collide-action solid rideable))
|
|
(set! (-> s3-0 transform-index) 3)
|
|
(set-vector! (-> s3-0 local-sphere) 0.0 29081.6 0.0 31948.8)
|
|
(set! (-> s4-0 total-prims) (the-as uint 1))
|
|
(set! (-> s4-0 root-prim) s3-0)
|
|
)
|
|
(pusher-init s4-0)
|
|
(set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
|
|
(let ((v1-12 (-> s4-0 root-prim)))
|
|
(set! (-> s4-0 backup-collide-as) (-> v1-12 prim-core collide-as))
|
|
(set! (-> s4-0 backup-collide-with) (-> v1-12 prim-core collide-with))
|
|
)
|
|
(set! (-> this root) s4-0)
|
|
)
|
|
(process-drawable-from-entity! this arg0)
|
|
(initialize-skeleton
|
|
this
|
|
(the-as skeleton-group (art-group-get-by-name *level* "skel-nest-piston" (the-as (pointer uint32) #f)))
|
|
(the-as pair 0)
|
|
)
|
|
(logclear! (-> this mask) (process-mask actor-pause))
|
|
(+! (-> this root trans y) 8192.0)
|
|
(set! (-> this y-level) (-> this root trans y))
|
|
(set! (-> this y-offset) 0.0)
|
|
(transform-post)
|
|
(go (method-of-object this idle))
|
|
(none)
|
|
)
|