jak-project/goal_src/jak2/levels/mars_tomb/widow2.gc
Hat Kid 67d4eda169
decomp: hover-* files, wasp, crimson-guard-hover, flamer, target-turret, drill-turret, jellyfish (#2198)
Manual patches:

- `drill-turret`: The static data for `*turret-13-path*`,
`*turret-14-path*` and `*turret-15-path*` was decompiled by hand and the
integers in the `set-speed-mult` events have been replaced with boxed
integer arrays that contain only that integer in order to make the
compiler happy. To that effect, the event handler in `target-turret` was
changed to access that array instead of just accessing the int.
- `hover-nav-control`: In `hover-nav-control::10`, `arg2` is usually a
`vector`, but there are some places where it is called with `#t` as
`arg2` and, subsequently, crashes the game because it tries to access
the `quad` of `arg2` if `arg2` is truthy. To mitigate this, the
condition `arg2` has been replaced with `(and (!= arg2 #t) arg2)` (in
this case, it would jump to the `else` that just resets the `dest-vel`
and `transv` `quad`s)
- `drill-baron`: The static data for `*drill-ship-turret-speed-event*`
has been decompiled by hand.

TODOs:
- Jellyfish crash the game
- Destroying the metalhead eggs that are on the breakable wall crashes
the game (already happened with the Peacemaker before)
- Figure out why static data of type `turret-path-event` doesn't
decompile

The docs for all the hover-nav and nav-network code could use some love
in the future, I'm not smart enough to figure out what any of that code
actually means, but it seems to work...

Also threw in the fix for the ▲ that was accidentally left commented
out.
2023-02-09 18:22:56 -05:00

400 lines
16 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: widow2.gc
;; name in dgo: widow2
;; dgos: TOA
;; DECOMP BEGINS
(defmethod deal-damage! widow-shot ((obj widow-shot) (arg0 process) (arg1 event-message-block))
"Constructs an [[attack-info]] according to the projectile's `options`"
(let ((t9-0 (method-of-type projectile deal-damage!)))
(when (t9-0 obj arg0 arg1)
(set! (-> obj hit-actor?) #t)
(if (= arg0 *target*)
(send-event (ppointer->process (-> obj parent)) 'shot-hit-target)
)
#t
)
)
)
(defmethod widow-method-44 widow ((obj widow) (arg0 vector) (arg1 vector))
(let ((gp-0 (new 'stack-no-clear 'collide-query)))
(set! (-> gp-0 start-pos quad) (-> arg0 quad))
(vector-normalize-copy! (-> gp-0 move-dist) arg1 81920.0)
(let ((v1-1 gp-0))
(set! (-> v1-1 radius) 4096.0)
(set! (-> v1-1 collide-with) (collide-spec enemy hit-by-others-list))
(set! (-> v1-1 ignore-process0) obj)
(set! (-> v1-1 ignore-process1) #f)
(set! (-> v1-1 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1))
(set! (-> v1-1 action-mask) (collide-action solid deadly))
)
(if (>= (fill-and-probe-using-line-sphere *collide-cache* gp-0) 0.0)
(return #f)
)
)
#t
)
;; WARN: Return type mismatch sound-id vs none.
(defmethod widow-method-45 widow ((obj widow) (arg0 vector) (arg1 vector) (arg2 vector))
(let ((s5-0 (new 'stack-no-clear 'projectile-init-by-other-params)))
(let ((f30-0 (/ 2013265900.0 (vector-length arg2)))
(s3-0 (new 'stack-no-clear 'vector))
)
(set! (-> s5-0 ent) (-> obj entity))
(set! (-> s5-0 charge) 1.0)
(set! (-> s5-0 options) (projectile-options account-for-target-velocity))
(set! (-> s5-0 pos quad) (-> arg1 quad))
(set! (-> s5-0 notify-handle) (process->handle obj))
(set! (-> s5-0 owner-handle) (the-as handle #f))
(set! (-> s5-0 ignore-handle) (process->handle obj))
(let* ((v1-13 *game-info*)
(a0-12 (+ (-> v1-13 attack-id) 1))
)
(set! (-> v1-13 attack-id) a0-12)
(set! (-> s5-0 attack-id) a0-12)
)
(set! (-> s5-0 timeout) (seconds 4))
(vector-normalize-copy! (-> s5-0 vel) arg2 491520.0)
(let ((f30-1 (fmin 16384.0 f30-0)))
(set-vector! s3-0 (-> arg2 z) (-> arg2 y) (- (-> arg2 x)) 1.0)
(vector-normalize! s3-0 (rand-vu-float-range (- f30-1) f30-1))
(vector+! (-> s5-0 vel) (-> s5-0 vel) s3-0)
(vector-cross! s3-0 s3-0 (-> s5-0 vel))
(vector-normalize! s3-0 (rand-vu-float-range (- f30-1) f30-1))
)
(vector+! (-> s5-0 vel) (-> s5-0 vel) s3-0)
)
(spawn-projectile widow-shot s5-0 obj *default-dead-pool*)
)
(if arg0
(sound-play "widow-fire")
)
(none)
)
(defmethod widow-method-46 widow ((obj widow) (arg0 vector) (arg1 int))
(let ((s4-0 (vector<-cspace! (new 'stack-no-clear 'vector) (-> obj node-list data arg1)))
(s3-0 (new 'stack-no-clear 'vector))
)
(set! (-> s3-0 quad) (-> obj node-list data arg1 bone transform vector 1 quad))
(if (widow-method-44 obj s4-0 s3-0)
(widow-method-45 obj arg0 s4-0 s3-0)
)
)
0
(none)
)
(defmethod deactivate widow ((obj widow))
(if (nonzero? (-> obj drill-spark-part))
(kill-and-free-particles (-> obj drill-spark-part))
)
(if (nonzero? (-> obj drill-spark-part-alt))
(kill-and-free-particles (-> obj drill-spark-part-alt))
)
(if (nonzero? (-> obj extract-stone-part))
(kill-and-free-particles (-> obj extract-stone-part))
)
(if (nonzero? (-> obj insert-stone-part))
(kill-and-free-particles (-> obj insert-stone-part))
)
(if (nonzero? (-> obj land-part))
(kill-and-free-particles (-> obj land-part))
)
(if (nonzero? (-> obj green-charge-part))
(kill-and-free-particles (-> obj green-charge-part))
)
(if (nonzero? (-> obj green-fire-part))
(kill-and-free-particles (-> obj green-fire-part))
)
(if (-> obj drill-sound-playing)
(sound-stop (the-as sound-id (-> obj drill-sound)))
)
(if (-> obj drill-sweeten-sound-playing)
(sound-stop (the-as sound-id (-> obj drill-sweeten-sound)))
)
(if (-> obj hover-sound-playing)
(sound-stop (the-as sound-id (-> obj hover-sound)))
)
(if (-> obj shake-sound-playing)
(sound-stop (the-as sound-id (-> obj shake-sound)))
)
((method-of-type process-drawable deactivate) obj)
(none)
)
;; WARN: Return type mismatch process-drawable vs widow.
(defmethod relocate widow ((obj widow) (arg0 int))
(if (nonzero? (-> obj left-cover-jm))
(&+! (-> obj left-cover-jm) arg0)
)
(if (nonzero? (-> obj right-cover-jm))
(&+! (-> obj right-cover-jm) arg0)
)
(if (nonzero? (-> obj left-drill-jm))
(&+! (-> obj left-drill-jm) arg0)
)
(if (nonzero? (-> obj right-drill-jm))
(&+! (-> obj right-drill-jm) arg0)
)
(if (nonzero? (-> obj drill-spark-part))
(&+! (-> obj drill-spark-part) arg0)
)
(if (nonzero? (-> obj drill-spark-part-alt))
(&+! (-> obj drill-spark-part-alt) arg0)
)
(if (nonzero? (-> obj extract-stone-part))
(&+! (-> obj extract-stone-part) arg0)
)
(if (nonzero? (-> obj insert-stone-part))
(&+! (-> obj insert-stone-part) arg0)
)
(if (nonzero? (-> obj land-part))
(&+! (-> obj land-part) arg0)
)
(if (nonzero? (-> obj green-charge-part))
(&+! (-> obj green-charge-part) arg0)
)
(if (nonzero? (-> obj green-fire-part))
(&+! (-> obj green-fire-part) arg0)
)
(dotimes (v1-44 5)
(if (nonzero? (-> obj lightning v1-44))
(&+! (-> obj lightning v1-44) arg0)
)
)
(the-as widow ((method-of-type process-drawable relocate) obj arg0))
)
;; WARN: Return type mismatch object vs none.
(defmethod init-from-entity! widow ((obj widow) (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-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
generic-attack
lunge
flop
punch
spin
roll
uppercut
bonk
tube
vehicle
flut-attack
board
mech-punch
dark-punch
dark-giant
)
)
(let ((s3-0 (new 'process 'collide-shape-prim-group s4-0 (the-as uint 1) 0)))
(set! (-> s4-0 total-prims) (the-as uint 2))
(set! (-> s3-0 prim-core collide-as) (collide-spec enemy))
(set! (-> s3-0 prim-core collide-with) (collide-spec jak bot player-list))
(set! (-> s3-0 prim-core action) (collide-action solid))
(set! (-> s3-0 transform-index) 3)
(set-vector! (-> s3-0 local-sphere) 0.0 0.0 9216.0 36864.0)
(set! (-> s4-0 root-prim) s3-0)
)
(let ((v1-14 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint 0) (the-as uint 0))))
(set! (-> v1-14 prim-core collide-as) (collide-spec enemy))
(set! (-> v1-14 prim-core collide-with) (collide-spec jak bot player-list))
(set! (-> v1-14 prim-core action) (collide-action solid))
(set! (-> v1-14 transform-index) 3)
(set-vector! (-> v1-14 local-sphere) 0.0 0.0 0.0 32768.0)
)
(set! (-> s4-0 nav-radius) 8192.0)
(let ((v1-16 (-> s4-0 root-prim)))
(set! (-> s4-0 backup-collide-as) (-> v1-16 prim-core collide-as))
(set! (-> s4-0 backup-collide-with) (-> v1-16 prim-core collide-with))
)
(set! (-> obj root) s4-0)
)
(process-drawable-from-entity! obj arg0)
(initialize-skeleton
obj
(the-as skeleton-group (art-group-get-by-name *level* "skel-widow" (the-as (pointer uint32) #f)))
(the-as pair 0)
)
(set! (-> obj skel generate-frame-function) create-interpolated2-joint-animation-frame)
(setup-masks (-> obj draw) 0 126)
(set! (-> obj root pause-adjust-distance) 245760.0)
(dotimes (v1-26 8)
(set! (-> obj catwalk v1-26) (the-as handle #f))
)
(let ((s4-2 (-> obj entity extra perm)))
(logior! (-> s4-2 status) (entity-perm-status bit-5))
0
(let ((s3-2 (new 'stack-no-clear 'vector)))
(set! (-> s3-2 quad) (-> arg0 extra trans quad))
(set! (-> s3-2 y) (+ -32768.0 (-> s3-2 y)))
(set! (-> s3-2 z) (+ 42475.52 (-> s3-2 z)))
(dotimes (s5-1 8)
(cond
((not (logtest? (the-as int (-> s4-2 user-object 1)) (ash 1 s5-1)))
(set! (-> obj catwalk s5-1) (ppointer->handle (process-spawn tomb-boss-catwalk s3-2 s5-1 :to obj)))
(if (not (handle->process (-> obj catwalk s5-1)))
(format 0 "catwalk ~D failed to spawn~%" s5-1)
)
)
(else
(send-event (handle->process (-> obj catwalk 0)) 'catwalk-hit s5-1)
)
)
)
)
)
(dotimes (v1-62 8)
(set! (-> obj bomb v1-62) (the-as handle #f))
)
(dotimes (v1-65 2)
(set! (-> obj ammos v1-65) (the-as handle #f))
(set! (-> obj ammo-timers v1-65) 0)
)
(set! (-> obj attack-from-high-deg) #f)
(set! (-> obj which-gun) 0)
(set! (-> obj which-pod) 0)
(set! (-> obj bomb-hits) 0)
(set! (-> obj flying) #f)
(set! (-> obj previous-anim) 0)
(set! (-> obj circle-center quad) (-> obj root trans quad))
(set! (-> obj circle-center z) (+ 40960.0 (-> obj circle-center z)))
(init (-> obj theta) 0.0 0.01 91.022224 0.9)
(init (-> obj tilt) 0.0 0.01 91.022224 0.9)
(set! (-> obj left-cover-jm) (new 'process 'joint-mod (joint-mod-mode joint-set*) obj 90))
(set! (-> obj right-cover-jm) (new 'process 'joint-mod (joint-mod-mode joint-set*) obj 91))
(widow-float-seeker-method-9 (-> obj left-cover-angle) 0.0 0.01 0.1 0.9 0.25)
(widow-float-seeker-method-9 (-> obj right-cover-angle) 0.0 0.01 0.1 0.9 0.25)
(set! (-> obj left-drill-jm) (new 'process 'joint-mod (joint-mod-mode joint-set*) obj 11))
(set! (-> obj right-drill-jm) (new 'process 'joint-mod (joint-mod-mode joint-set*) obj 44))
(init (-> obj drill-speed) 0.0 0.01 0.1 0.9)
(let ((s5-2 (new 'stack-no-clear 'vector)))
(set! (-> s5-2 quad) (-> obj root trans quad))
(set! (-> obj baron) (process-spawn
manipy
:init manipy-init
s5-2
(-> obj entity)
(art-group-get-by-name *level* "skel-baron" (the-as (pointer uint32) #f))
#f
0
:to obj
)
)
)
(logior! (-> obj baron 0 draw global-effect) (draw-control-global-effect disable-envmap))
(send-event (ppointer->process (-> obj baron)) 'anim-mode 'clone-anim)
(set! (-> obj baron 0 draw light-index) (mod (-> obj draw light-index) (the-as uint 10)))
(let ((v1-106 (-> obj baron)))
(if v1-106
(logclear! (-> v1-106 0 mask) (process-mask actor-pause))
)
)
(set! (-> obj pod) (ppointer->handle (process-spawn baron-pod (-> obj root trans) :to obj)))
(set! (-> obj heart) (the-as handle #f))
(set! (-> obj drill-spark-part) (create-launch-control (-> *part-group-id-table* 713) obj))
(set! (-> obj drill-spark-part-alt) (create-launch-control (-> *part-group-id-table* 714) obj))
(set! (-> obj extract-stone-time) 0)
(set! (-> obj extract-stone-part) (create-launch-control (-> *part-group-id-table* 715) obj))
(set! (-> obj insert-stone-time) 0)
(set! (-> obj insert-stone-part) (create-launch-control (-> *part-group-id-table* 716) obj))
(set! (-> obj land-part) (create-launch-control (-> *part-group-id-table* 730) obj))
(set! (-> obj green-charge-part) (create-launch-control (-> *part-group-id-table* 731) obj))
(set! (-> obj green-fire-part) (create-launch-control (-> *part-group-id-table* 732) obj))
(add-connection *part-engine* obj 73 obj 3251 (new 'static 'vector :w 819200.0))
(add-connection *part-engine* obj 77 obj 3251 (new 'static 'vector :w 819200.0))
(add-connection *part-engine* obj 78 obj 3251 (new 'static 'vector :w 819200.0))
(dotimes (s5-4 5)
(set! (-> obj lightning s5-4) (new
'process
'lightning-control
(new 'static 'lightning-spec
:name #f
:flags (lightning-spec-flags lsf0)
:start-color (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80)
:end-color (new 'static 'rgba :r #x80 :g #x80 :b #x80 :a #x80)
:fade-to-color (new 'static 'rgba :r #xbf :b #x8f :a #x5)
:fade-start-factor 0.2
:fade-time 120.0
:texture (new 'static 'texture-id :index #x7 :page #x8c7)
:reduction 0.4
:num-points 48
:box-size 57344.0
:merge-factor 0.5
:merge-count 2
:radius 9216.0
:duration -1.0
:sound #f
)
obj
0.0
)
)
(let ((v1-148 (-> obj lightning s5-4))
(a0-97 0)
)
(let ((a1-48 (!= a0-97 (-> v1-148 state mode))))
(case a0-97
((3)
(if a1-48
(set! (-> v1-148 state counter) 0.0)
)
)
((1)
(set! (-> v1-148 state start-color) (-> v1-148 spec start-color))
(set! (-> v1-148 state end-color) (-> v1-148 spec end-color))
)
)
)
(set! (-> v1-148 state mode) (the-as lightning-mode a0-97))
)
)
(set! (-> obj catwalk-sound) (the-as uint (new-sound-id)))
(set! (-> obj drill-sound) (the-as uint (new-sound-id)))
(set! (-> obj drill-sound-playing) #f)
(set! (-> obj drill-sweeten-sound) (the-as uint (new-sound-id)))
(set! (-> obj drill-sweeten-sound-playing) #f)
(set! (-> obj hover-sound) (the-as uint (new-sound-id)))
(set! (-> obj hover-sound-playing) #f)
(set! (-> obj shake-sound) (the-as uint (new-sound-id)))
(set! (-> obj shake-sound-playing) #f)
(set! (-> obj hud) (the-as handle #f))
(set! (-> obj last-want-stone-talker) 0)
(set! (-> obj last-general-flying-talker) 0)
(set! (-> obj last-launch-droids-talker) 0)
(set! (-> obj last-launch-bombs-talker) 0)
(set! (-> obj last-shoot-gun-talker) 0)
(set! (-> obj last-stone-charge-up-talker) 0)
(set! (-> obj last-after-stone-shot-talker) 0)
(set! (-> obj last-leave-perch-talker) 0)
(set! (-> obj last-damaged-talker) 0)
(set! (-> obj kicked-bombs) 0)
(set! (-> obj launch-stages-completed) 0)
(set! (-> obj current-shoot-stage) 0)
(set! (-> obj last-gun-hit-stage) 0)
(set! (-> obj gun-hits) 0)
(set! (-> obj last-attack-id) (the-as uint 0))
(if (task-node-closed? (game-task-node tomb-boss-resolution))
(go (method-of-object obj beaten))
(go (method-of-object obj hidden))
)
(none)
)