jak-project/goal_src/jak2/levels/ruins/pillar-collapse.gc
Hat Kid e0ee9b6a81
decomp: drill-obs, drill-obs2, drillmid-obs, drill-panel, drill-spool (#2152)
Co-authored-by: Tyler Wilding <xtvaser@gmail.com>
2023-01-28 15:41:48 -05:00

414 lines
16 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: pillar-collapse.gc
;; name in dgo: pillar-collapse
;; dgos: RUI
;; DECOMP BEGINS
(deftype ruins-pillar-collapse (process-drawable)
((root-override collide-shape-moving :offset 128)
(player-attack-id int32 :offset-assert 200)
(fall-anim-index int32 :offset-assert 204)
(hit-points int8 :offset-assert 208)
(mesh-trans uint8 3 :offset-assert 209)
(mesh-joint joint 2 :offset-assert 212)
(deadly? symbol :offset 216)
(art-name string :offset 220)
(anim spool-anim :offset 224)
)
:heap-base #x70
:method-count-assert 24
:size-assert #xe4
:flag-assert #x18007000e4
(:methods
(idle () _type_ :state 20)
(bump () _type_ :state 21)
(hit () _type_ :state 22)
(fall (symbol) _type_ :state 23)
)
)
(defskelgroup skel-ruins-pillar-collapse-1 ruins-pillar-collapse ruins-pillar-collapse-lod0-jg ruins-pillar-collapse-1-idle-ja
((ruins-pillar-collapse-lod0-mg (meters 999999)))
:bounds (static-spherem 0 12 16 30)
)
(defskelgroup skel-ruins-pillar-collapse-2 ruins-pillar-collapse ruins-pillar-collapse-lod0-jg ruins-pillar-collapse-2-idle-ja
((ruins-pillar-collapse-lod0-mg (meters 999999)))
:bounds (static-spherem 0 12 0 17)
)
(defskelgroup skel-ruins-pillar-collapse-3 ruins-pillar-collapse ruins-pillar-collapse-lod0-jg ruins-pillar-collapse-3-idle-ja
((ruins-pillar-collapse-lod0-mg (meters 999999)))
:bounds (static-spherem 0 12 0 17)
)
(defstate idle (ruins-pillar-collapse)
:virtual #t
:event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block))
(case event-type
(('attack)
(when (task-node-closed? (game-task-node ruins-mech-introduction))
(let* ((gp-1 (the-as attack-info (-> event param 1)))
(s4-0 (-> gp-1 id))
(s5-0 (vector-x-quaternion! (new-stack-vector0) (-> self root-override quat)))
(a0-6 (vector-z-quaternion! (new-stack-vector0) (-> self root-override quat)))
(v1-4
(vector-! (new-stack-vector0) (-> (the-as process-drawable proc) root trans) (-> self root-override trans))
)
)
0.0
0.0
(when (!= s4-0 (-> self player-attack-id))
(set! (-> self player-attack-id) (the-as int s4-0))
(let* ((f0-3 (vector-dot s5-0 v1-4))
(f1-1 (vector-dot a0-6 v1-4))
(a0-8 (-> gp-1 mode))
(v1-6 (cond
((= a0-8 'mech-punch)
(and (< f1-1 0.0) (< (fabs (* 0.5 f0-3)) (fabs f1-1)))
)
((= a0-8 'crush)
(< (sqrtf (+ (* (-> v1-4 x) (-> v1-4 x)) (* (-> v1-4 z) (-> v1-4 z)))) 40960.0)
)
((= a0-8 'debug)
#t
)
)
)
)
(cond
(v1-6
(go-virtual hit)
)
(else
(go-virtual bump)
#f
)
)
)
)
)
)
)
(('look-at-point)
(send-event (ppointer->process (-> self child)) 'look-at-point)
)
(('combo)
#t
)
)
)
:enter (behavior ()
(let ((s5-0 (matrix<-transformq! (new 'stack-no-clear 'matrix) (the-as transformq (-> self root-override trans)))))
(if (string= (-> self name) "ruins-pillar-collapse-9")
(mech-target-spawn
(vector-matrix*! (new 'stack-no-clear 'vector) (new 'static 'vector :y 18432.0 :z 8192.0 :w 1.0) s5-0)
self
(-> self root-override quat)
(-> self entity)
)
(mech-target-spawn
(vector-matrix*! (new 'stack-no-clear 'vector) (new 'static 'vector :y 18432.0 :z -8192.0 :w 1.0) s5-0)
self
(-> self root-override quat)
(-> self entity)
)
)
)
(none)
)
:exit (behavior ()
(while (-> self child)
(deactivate (-> self child 0))
)
(none)
)
:code (behavior ()
(if (task-node-closed? (game-task-node ruins-mech-introduction))
(add-process *gui-control* self (gui-channel art-load) (gui-action queue) (-> self anim name) -99.0 0)
)
(ja :num-func num-func-identity :frame-num 0.0)
(logior! (-> self mask) (process-mask sleep))
(suspend)
0
(none)
)
:post (the-as (function none :behavior ruins-pillar-collapse) transform-post)
)
(defstate bump (ruins-pillar-collapse)
:virtual #t
:event (-> (method-of-type ruins-pillar-collapse idle) event)
:trans (the-as (function none :behavior ruins-pillar-collapse) rider-trans)
:code (behavior ()
(go-virtual idle)
(none)
)
:post (the-as (function none :behavior ruins-pillar-collapse) rider-post)
)
(defstate hit (ruins-pillar-collapse)
:virtual #t
:event (-> (method-of-type ruins-pillar-collapse idle) event)
:trans (the-as (function none :behavior ruins-pillar-collapse) rider-trans)
:code (behavior ()
(+! (-> self hit-points) -1)
(if (zero? (-> self hit-points))
(go-virtual fall #f)
)
(go-virtual idle)
(none)
)
:post (the-as (function none :behavior ruins-pillar-collapse) rider-post)
)
(defstate fall (ruins-pillar-collapse)
:virtual #t
:event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block))
(case event-type
(('touch 'attack)
(let* ((s5-0 (-> event param 0))
(s4-0 proc)
(gp-0 (if (type? s4-0 process-focusable)
s4-0
)
)
(a1-4 (if s5-0
((method-of-type touching-shapes-entry prims-touching?)
(the-as touching-shapes-entry s5-0)
(-> self root-override)
(the-as uint 2)
)
)
)
)
(when (and gp-0 a1-4)
(let ((s4-1 (get-intersect-point
(new 'stack-no-clear 'vector)
a1-4
(-> self root-override)
(the-as touching-shapes-entry s5-0)
)
)
)
(when (and (< (-> (get-trans (the-as process-focusable gp-0) 3) y) (-> s4-1 y))
(< 40960.0 (vector-vector-distance s4-1 (-> self root-override trans)))
)
(let ((a1-8 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-8 from) (process->ppointer self))
(set! (-> a1-8 num-params) 2)
(set! (-> a1-8 message) 'attack)
(set! (-> a1-8 param 0) s5-0)
(let ((v1-13 (new 'static 'attack-info :mask (attack-info-mask mode id))))
(let* ((a0-7 *game-info*)
(a2-5 (+ (-> a0-7 attack-id) 1))
)
(set! (-> a0-7 attack-id) a2-5)
(set! (-> v1-13 id) a2-5)
)
(set! (-> v1-13 mode) 'crush)
(set! (-> a1-8 param 1) (the-as uint v1-13))
)
(send-event-function gp-0 a1-8)
)
)
)
)
)
)
)
)
:trans (the-as (function none :behavior ruins-pillar-collapse) rider-trans)
:code (behavior ((arg0 symbol))
(set! (-> self draw bounds z) 61440.0)
(set! (-> self draw bounds w) 217088.0)
(set! (-> self root-override root-prim local-sphere w) 217088.0)
(set! (-> (the-as collide-shape-prim-group (-> self root-override root-prim)) child 0 prim-core collide-with)
(collide-spec)
)
(set! (-> (the-as collide-shape-prim-group (-> self root-override root-prim)) child 0 prim-core collide-as)
(collide-spec)
)
(process-entity-status! self (entity-perm-status subtask-complete) #t)
(let* ((s5-0 (-> self draw art-group))
(s4-0 (method-of-object s5-0 get-art-by-name-method))
)
(format (clear *temp-string*) "~S-end" (-> self art-name))
(let ((s5-1 (s4-0 s5-0 *temp-string* art-joint-anim)))
(when (not arg0)
(talker-spawn-func (-> *talker-speech* 456) *entity-pool* (target-pos 0) (the-as region #f))
(ja-play-spooled-anim (-> self anim) (ja-group) (the-as art-joint-anim s5-1) (the-as (function process-drawable symbol) false-func))
)
(set! (-> self event-hook) #f)
(ja-channel-set! 1)
(set! (-> self skel root-channel 0 frame-group) (the-as art-joint-anim s5-1))
)
)
(suspend)
(logior! (-> self mask) (process-mask sleep))
(suspend)
0
(none)
)
:post (the-as (function none :behavior ruins-pillar-collapse) rider-post)
)
;; WARN: Return type mismatch object vs none.
(defmethod init-from-entity! ruins-pillar-collapse ((obj ruins-pillar-collapse) (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"
(local-vars (sv-16 collide-shape-prim-mesh) (sv-32 symbol) (sv-48 type) (sv-64 collide-shape-moving))
(stack-size-set! (-> obj main-thread) 512)
(set! (-> obj mask) (logior (process-mask collectable) (-> obj mask)))
(dotimes (v1-3 3)
(set! (-> obj mesh-trans v1-3) (the-as uint v1-3))
)
(let ((s4-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player))))
(set! (-> s4-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> s4-0 reaction) cshape-reaction-default)
(set! (-> s4-0 no-reaction)
(the-as (function collide-shape-moving collide-query vector vector object) nothing)
)
(set! (-> s4-0 penetrated-by) (penetrate))
(let ((s3-0 (new 'process 'collide-shape-prim-group s4-0 (the-as uint 33) 0)))
(set! (-> s4-0 total-prims) (the-as uint 34))
(set! (-> s3-0 prim-core collide-as) (collide-spec obstacle))
(set! (-> s3-0 prim-core action) (collide-action solid rideable))
(set! (-> s3-0 transform-index) 0)
(set-vector! (-> s3-0 local-sphere) 0.0 49152.0 0.0 69632.0)
(set! (-> s4-0 root-prim) s3-0)
(let* ((s2-0 (the-as object '((5 22 61440)
(3 21 18432)
(4 22 61440)
(6 46 8192)
(7 47 6144)
(8 48 6963)
(9 49 6963)
(10 53 6963)
(11 54 6144)
(12 61 8192)
(13 62 10240)
(14 63 6963)
(15 64 6963)
(17 66 9011)
(18 67 16384)
(19 68 8192)
(20 69 6144)
(21 70 6553)
(22 71 9420)
(23 72 5734)
(24 73 7782)
(25 74 5734)
(26 75 8192)
(27 76 5734)
(28 77 5734)
(29 78 10240)
(30 79 6144)
(31 80 6144)
(32 81 6144)
(33 82 6963)
(34 83 9830)
(35 84 8192)
(16 65 8192)
)
)
)
(s1-0 (-> (the-as pair s2-0) car))
)
(while (not (null? s2-0))
(let ((s0-0 (method-of-type collide-shape-prim-mesh new)))
(set! sv-32 'process)
(set! sv-48 collide-shape-prim-mesh)
(set! sv-64 s4-0)
(let ((a3-2 (command-get-int (-> (the-as pair s1-0) car) 0))
(t0-1 0)
)
(set! sv-16 (s0-0 sv-32 sv-48 sv-64 (the-as uint a3-2) (the-as uint t0-1)))
)
)
(let ((s0-1 sv-16))
(set! (-> s0-1 prim-core collide-as) (-> s3-0 prim-core collide-as))
(set! (-> s0-1 prim-core collide-with) (-> s3-0 prim-core collide-with))
(set! (-> s0-1 prim-core action) (-> s3-0 prim-core action))
(set! (-> s0-1 transform-index) (command-get-int (-> (the-as pair (-> (the-as pair s1-0) cdr)) car) 0))
)
(set-vector!
(-> sv-16 local-sphere)
0.0
0.0
0.0
(command-get-float (-> (the-as pair (-> (the-as pair (-> (the-as pair s1-0) cdr)) cdr)) car) 0.0)
)
(set! s2-0 (-> (the-as pair s2-0) cdr))
(set! s1-0 (-> (the-as pair s2-0) car))
)
)
)
(set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
(let ((v1-30 (-> s4-0 root-prim)))
(set! (-> s4-0 backup-collide-as) (-> v1-30 prim-core collide-as))
(set! (-> s4-0 backup-collide-with) (-> v1-30 prim-core collide-with))
)
(set! (-> obj root-override) s4-0)
)
(process-drawable-from-entity! obj arg0)
(set! (-> obj mesh-trans 0) (the-as uint 1))
(set! (-> obj mesh-trans 1) (the-as uint 2))
(set! (-> obj mesh-trans 2) (the-as uint 0))
(let ((s5-1 (res-lump-struct (-> obj entity) 'art-name structure)))
(set! (-> obj art-name) (the-as string s5-1))
(cond
((string= (the-as string s5-1) "ruins-pillar-collapse-1")
(let ((v1-38 (-> obj root-override root-prim local-sphere)))
(set! (-> v1-38 y) 49152.0)
(set! (-> v1-38 z) 65536.0)
(set! (-> v1-38 w) 122880.0)
)
(set! (-> obj anim) (new 'static 'spool-anim
:name "ruins-pillar-collapse-1"
:anim-name "1-break-center"
:parts 2
:command-list '()
)
)
)
((string= (the-as string s5-1) "ruins-pillar-collapse-2")
(set! (-> obj anim) (new 'static 'spool-anim
:name "ruins-pillar-collapse-2"
:anim-name "2-break-center"
:parts 2
:command-list '()
)
)
(set-yaw-angle-clear-roll-pitch! (-> obj root-override) (+ 32768.0 (y-angle (-> obj root-override))))
)
((string= (the-as string s5-1) "ruins-pillar-collapse-3")
(set! (-> obj anim) (new 'static 'spool-anim
:name "ruins-pillar-collapse-3"
:anim-name "3-break-center"
:parts 2
:command-list '()
)
)
(set-yaw-angle-clear-roll-pitch! (-> obj root-override) (+ 32768.0 (y-angle (-> obj root-override))))
)
)
(initialize-skeleton-by-name obj (the-as string s5-1))
)
(set! (-> obj hit-points) 1)
(set! (-> obj deadly?) #f)
(if (and (-> obj entity) (logtest? (-> obj entity extra perm status) (entity-perm-status subtask-complete)))
(go (method-of-object obj fall) #t)
(go (method-of-object obj idle))
)
(none)
)