jak-project/goal_src/jak2/levels/common/metalhead-projectile.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

956 lines
34 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: metalhead-projectile.gc
;; name in dgo: metalhead-projectile
;; dgos: GAME, COMMON
;; DECOMP BEGINS
(defpart 621
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x80 :page #xc))
(sp-func spt-birth-func 'birth-func-set-quat)
(sp-flt spt-num 1.0)
(sp-flt spt-scale-x (meters 0.25))
(sp-flt spt-scale-y (meters 12))
(sp-flt spt-r 128.0)
(sp-flt spt-g 128.0)
(sp-flt spt-b 128.0)
(sp-rnd-flt spt-a 32.0 64.0 1.0)
(sp-int spt-timer 5)
(sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-14 left-multiply-quat)
)
)
(defpart 622
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xca :page #xc))
(sp-flt spt-num 1.0)
(sp-flt spt-scale-x (meters 3))
(sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
(sp-copy-from-other spt-scale-y -4)
(sp-flt spt-r 128.0)
(sp-flt spt-g 0.0)
(sp-flt spt-b 128.0)
(sp-flt spt-a 64.0)
(sp-flt spt-scalevel-x (meters -0.075))
(sp-copy-from-other spt-scalevel-y -4)
(sp-flt spt-fade-a -1.6)
(sp-int spt-timer 40)
(sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14)
)
)
(defpart 623
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x14 :page #xc))
(sp-flt spt-num 16.0)
(sp-rnd-flt spt-z (meters 0) (meters -2) 1.0)
(sp-rnd-flt spt-scale-x (meters 0.5) (meters 0.5) 1.0)
(sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 3600.0) 1.0)
(sp-rnd-flt spt-scale-y (meters 0.5) (meters 0.5) 1.0)
(sp-flt spt-r 128.0)
(sp-flt spt-g 128.0)
(sp-flt spt-b 128.0)
(sp-flt spt-a 64.0)
(sp-rnd-flt spt-fade-g -3.2 -6.4 1.0)
(sp-rnd-flt spt-fade-a -1.6 -6.4 1.0)
(sp-rnd-flt spt-accel-y -0.68266666 -0.68266666 1.0)
(sp-int spt-timer 80)
(sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3)
(sp-flt spt-rotate-y (degrees 0.0))
)
)
(defpart 624
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x81 :page #xc))
(sp-func spt-birth-func 'birth-func-set-quat)
(sp-flt spt-num 1.0)
(sp-flt spt-scale-x (meters 2))
(sp-flt spt-scale-y (meters 4.5))
(sp-flt spt-r 128.0)
(sp-flt spt-g 128.0)
(sp-flt spt-b 128.0)
(sp-flt spt-a 128.0)
(sp-flt spt-fade-a -3.6571429)
(sp-int spt-timer 35)
(sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 left-multiply-quat)
)
)
(defpart 625
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc))
(sp-flt spt-num 1.0)
(sp-flt spt-scale-x (meters 2))
(sp-flt spt-rot-x 819.2)
(sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 3600.0) 1.0)
(sp-copy-from-other spt-scale-y -4)
(sp-flt spt-r 128.0)
(sp-rnd-flt spt-g 0.0 64.0 1.0)
(sp-flt spt-b 128.0)
(sp-flt spt-a 255.0)
(sp-flt spt-omega 822067.2)
(sp-flt spt-scalevel-x (meters 0.10666667))
(sp-copy-from-other spt-scalevel-y -4)
(sp-flt spt-fade-a -7.285714)
(sp-int spt-timer 35)
(sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow)
(sp-flt spt-userdata 1024.0)
)
)
(defpartgroup group-metalhead-shot-hit
:id 141
:duration (seconds 1)
:flags (use-local-clock)
:bounds (static-bspherem 0 0 0 8)
:parts ((sp-item 626 :period 600 :length 5)
(sp-item 627 :fade-after (meters 100) :flags (bit6) :period 600 :length 5)
(sp-item 628 :flags (bit6) :period 600 :length 5)
(sp-item 629 :flags (bit6) :period 600 :length 5)
(sp-item 630 :period 600 :length 5)
(sp-item 631 :fade-after (meters 50) :falloff-to (meters 50) :period 600 :length 5)
)
)
(defpart 629
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x33 :page #xc))
(sp-flt spt-num 1.0)
(sp-flt spt-scale-x (meters 1))
(sp-flt spt-rot-x 204.8)
(sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
(sp-copy-from-other spt-scale-y -4)
(sp-flt spt-r 255.0)
(sp-rnd-flt spt-g 0.0 128.0 1.0)
(sp-flt spt-b 255.0)
(sp-flt spt-a 12.0)
(sp-flt spt-scalevel-x (meters 0.26666668))
(sp-copy-from-other spt-scalevel-y -4)
(sp-flt spt-fade-a -0.34285715)
(sp-int spt-timer 40)
(sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow)
(sp-flt spt-userdata 4096.0)
)
)
(defpart 630
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :page #xc))
(sp-rnd-flt spt-num 8.0 8.0 1.0)
(sp-rnd-flt spt-scale-x (meters 1) (meters 0.5) 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 128.0 128.0 1.0)
(sp-rnd-flt spt-g 0.0 64.0 1.0)
(sp-rnd-flt spt-b 128.0 128.0 1.0)
(sp-rnd-flt spt-a 16.0 48.0 1.0)
(sp-rnd-flt spt-vel-y (meters 0.013333334) (meters 0.04) 1.0)
(sp-rnd-flt spt-scalevel-x (meters 0.0016666667) (meters 0.013333334) 1.0)
(sp-rnd-flt spt-rotvel-z (degrees -0.2) (degrees 0.4) 1.0)
(sp-copy-from-other spt-scalevel-y -4)
(sp-flt spt-fade-r -0.30476192)
(sp-flt spt-fade-g -0.35555556)
(sp-flt spt-fade-b -0.17777778)
(sp-flt spt-fade-a -0.15238096)
(sp-rnd-flt spt-accel-y -0.68266666 -0.68266666 1.0)
(sp-flt spt-friction 0.9)
(sp-int spt-timer 420)
(sp-cpuinfo-flags sp-cpuinfo-flag-2)
(sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 3600.0) 1.0)
(sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 3600.0) 1.0)
)
)
(defpart 631
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x14 :page #xc))
(sp-rnd-flt spt-num 20.0 10.0 1.0)
(sp-flt spt-y (meters 0.25))
(sp-rnd-flt spt-scale-x (meters 0.075) (meters 0.05) 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-flt spt-r 128.0)
(sp-rnd-flt spt-g 0.0 128.0 1.0)
(sp-flt spt-b 128.0)
(sp-rnd-flt spt-a 64.0 32.0 1.0)
(sp-rnd-flt spt-omega 4.096 4.096 1.0)
(sp-rnd-flt spt-vel-y (meters 0.033333335) (meters 0.1) 1.0)
(sp-rnd-int-flt spt-rotvel-z (degrees -2.4) 1 873.81335)
(sp-flt spt-fade-g -0.85333335)
(sp-flt spt-fade-a 0.0)
(sp-rnd-flt spt-accel-y -1.3653333 -5.4613333 1.0)
(sp-rnd-flt spt-friction 0.9 0.02 1.0)
(sp-int spt-timer 150)
(sp-cpuinfo-flags sp-cpuinfo-flag-0 sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14)
(sp-func spt-func 'sparticle-motion-blur)
(sp-int spt-next-time 100)
(sp-launcher-by-id spt-next-launcher 632)
(sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 360.0) 1.0)
(sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
)
)
(defpart 632
:init-specs ((sp-rnd-flt spt-fade-a -0.48 -0.48 1.0))
)
(defpart 627
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc))
(sp-flt spt-num 1.0)
(sp-flt spt-scale-x (meters 4))
(sp-flt spt-rot-x 819.2)
(sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
(sp-copy-from-other spt-scale-y -4)
(sp-flt spt-r 255.0)
(sp-flt spt-g 128.0)
(sp-rnd-flt spt-b 128.0 128.0 1.0)
(sp-flt spt-a 128.0)
(sp-flt spt-rotvel-z (degrees -0.1))
(sp-flt spt-fade-a -1.6)
(sp-int spt-timer 80)
(sp-cpuinfo-flags sp-cpuinfo-flag-0 sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow)
(sp-flt spt-userdata -4096.0)
(sp-launcher-by-id spt-next-launcher 633)
)
)
(defpart 633
:init-specs ((sp-rnd-flt spt-scale-x (meters 2) (meters 0.5) 1.0)
(sp-copy-from-other spt-scale-y -4)
(sp-flt spt-r 255.0)
(sp-rnd-flt spt-g 0.0 64.0 1.0)
(sp-rnd-flt spt-b 128.0 128.0 1.0)
(sp-int spt-next-time 5)
(sp-launcher-by-id spt-next-launcher 633)
)
)
(defpart 628
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc))
(sp-flt spt-num 2.0)
(sp-flt spt-scale-x (meters 1))
(sp-flt spt-rot-x 819.2)
(sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
(sp-copy-from-other spt-scale-y -4)
(sp-flt spt-r 255.0)
(sp-rnd-flt spt-g 0.0 64.0 1.0)
(sp-rnd-flt spt-b 128.0 128.0 1.0)
(sp-flt spt-a 48.0)
(sp-flt spt-scalevel-x (meters 0.12857144))
(sp-rnd-flt spt-rotvel-z (degrees -0.3) (degrees 0.6) 1.0)
(sp-copy-from-other spt-scalevel-y -4)
(sp-flt spt-fade-g -2.1333334)
(sp-flt spt-fade-b -2.1333334)
(sp-int spt-timer 80)
(sp-cpuinfo-flags sp-cpuinfo-flag-0 sp-cpuinfo-flag-2 glow)
(sp-flt spt-userdata -4096.0)
(sp-int spt-next-time 20)
(sp-launcher-by-id spt-next-launcher 634)
)
)
(defpart 634
:init-specs ((sp-flt spt-scale-x (meters 4.5))
(sp-copy-from-other spt-scale-y -4)
(sp-flt spt-scalevel-x (meters -0.06666667))
(sp-copy-from-other spt-scalevel-y -4)
(sp-flt spt-fade-g -0.53333336)
(sp-flt spt-fade-a -0.8)
)
)
(defpart 626
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc))
(sp-flt spt-num 1.0)
(sp-flt spt-scale-x (meters 1))
(sp-rnd-flt spt-rot-z (degrees 0.0) (degrees 360.0) 1.0)
(sp-copy-from-other spt-scale-y -4)
(sp-flt spt-r 255.0)
(sp-flt spt-g 255.0)
(sp-flt spt-b 255.0)
(sp-flt spt-a 96.0)
(sp-flt spt-scalevel-x (meters 0.16666667))
(sp-flt spt-rotvel-z (degrees 0.3))
(sp-copy-from-other spt-scalevel-y -4)
(sp-int spt-timer 55)
(sp-cpuinfo-flags sp-cpuinfo-flag-0 sp-cpuinfo-flag-2 sp-cpuinfo-flag-3)
(sp-int spt-next-time 15)
(sp-launcher-by-id spt-next-launcher 635)
)
)
(defpart 635
:init-specs ((sp-flt spt-scale-x (meters 3.5))
(sp-copy-from-other spt-scale-y -4)
(sp-flt spt-scalevel-x (meters -0.0875))
(sp-copy-from-other spt-scalevel-y -4)
(sp-flt spt-fade-b -6.4)
)
)
(defpartgroup group-metalhead-shot-die
:id 142
:duration (seconds 0.017)
:flags (use-local-clock)
:bounds (static-bspherem 0 0 0 8)
:parts ((sp-item 209))
)
(defpart 636
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xca :page #xc))
(sp-flt spt-num 1.0)
(sp-flt spt-scale-x (meters 2.5))
(sp-flt spt-rot-x 409.6)
(sp-copy-from-other spt-scale-y -4)
(sp-flt spt-r 255.0)
(sp-flt spt-g 192.0)
(sp-flt spt-b 64.0)
(sp-flt spt-a 16.0)
(sp-int spt-timer 5)
(sp-cpuinfo-flags sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 glow)
(sp-flt spt-userdata 819.2)
)
)
(deftype metalhead-shot (projectile)
((tail-pos vector :inline :offset-assert 480)
)
:heap-base #x170
:method-count-assert 40
:size-assert #x1f0
:flag-assert #x28017001f0
)
(defmethod draw-laser-sight metalhead-shot ((obj metalhead-shot))
"TODO - confirm If applicable, draw the laser sight particles"
(draw-beam (-> *part-id-table* 624) (-> obj tail-pos) (-> obj starting-dir) #f #t)
(let* ((a0-3 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> obj starting-dir) 2048.0))
(v1-2 (vector+! (new 'stack-no-clear 'vector) (-> obj tail-pos) a0-3))
(t9-2 sp-launch-particles-var)
(a0-4 *sp-particle-system-2d*)
(a1-4 (-> *part-id-table* 625))
(a2-2 *launch-matrix*)
)
(set! (-> a2-2 trans quad) (-> v1-2 quad))
(t9-2 a0-4 a1-4 a2-2 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0)
)
0
(none)
)
(defmethod spawn-impact-particles metalhead-shot ((obj metalhead-shot))
"Spawns associated particles with the projectile if applicable"
(rlet ((acc :class vf)
(vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
(vf7 :class vf)
)
(init-vf0-vector)
(let* ((gp-0 (-> obj root-override trans))
(a1-0 (-> obj tail-pos))
(s5-1 (vector-! (new 'stack-no-clear 'vector) gp-0 a1-0))
(f30-0 (vector-length s5-1))
)
(let ((s4-0 (new 'stack-no-clear 'vector)))
(let ((v1-4 a1-0))
(let ((a0-2 s5-1))
(let ((a2-1 0.8))
(.mov vf7 a2-1)
)
(.lvf vf5 (&-> a0-2 quad))
)
(.lvf vf4 (&-> v1-4 quad))
)
(.add.x.vf vf6 vf0 vf0 :mask #b1000)
(.mul.x.vf acc vf5 vf7 :mask #b111)
(.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111)
(.svf (&-> s4-0 quad) vf6)
(let ((f28-0 (-> *part-id-table* 621 init-specs 4 initial-valuef)))
(set! (-> *part-id-table* 621 init-specs 4 initial-valuef) (fmin f28-0 (vector-length s5-1)))
(draw-beam (-> *part-id-table* 621) a1-0 s5-1 #f #t)
(set! (-> *part-id-table* 621 init-specs 4 initial-valuef) f28-0)
)
(vector-normalize! s5-1 1.0)
(let ((t9-2 sp-launch-particles-var)
(a0-5 *sp-particle-system-2d*)
(a1-2 (-> *part-id-table* 622))
(a2-3 *launch-matrix*)
)
(set! (-> a2-3 trans quad) (-> s4-0 quad))
(t9-2 a0-5 a1-2 a2-3 (the-as sparticle-launch-state #f) (the-as sparticle-launch-control #f) 1.0)
)
)
(let ((s4-1 (new 'stack-no-clear 'matrix))
(f26-0 (* 0.000020345053 f30-0))
(f30-1 (-> *part-id-table* 623 init-specs 3 initial-valuef))
(f28-1 (-> *part-id-table* 623 init-specs 5 initial-valuef))
)
(forward-up->inv-matrix s4-1 s5-1 *up-vector*)
(set! (-> s4-1 trans quad) (-> gp-0 quad))
(set! (-> *part-id-table* 623 init-specs 3 initial-valuef) (* f26-0 f30-1))
(set! (-> *part-id-table* 623 init-specs 5 initial-valuef) (* f26-0 f28-1))
(sp-launch-particles-var
*sp-particle-system-2d*
(-> *part-id-table* 623)
s4-1
(the-as sparticle-launch-state #f)
(the-as sparticle-launch-control #f)
1.0
)
(set! (-> *part-id-table* 623 init-specs 3 initial-valuef) f30-1)
(set! (-> *part-id-table* 623 init-specs 5 initial-valuef) f28-1)
)
)
0
(none)
)
)
(defmethod spawn-shell-particles metalhead-shot ((obj metalhead-shot))
"TODO - confirm"
(let* ((s5-0 (-> obj root-override))
(v1-2 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> obj tail-pos) (-> s5-0 trans)) 2048.0))
(gp-0 (new 'stack-no-clear 'vector))
)
(set! (-> gp-0 quad) (-> s5-0 trans quad))
(vector+! gp-0 gp-0 v1-2)
(let ((s5-1 (get-process *default-dead-pool* part-tracker #x4000)))
(when s5-1
(let ((t9-2 (method-of-type part-tracker activate)))
(t9-2
(the-as part-tracker s5-1)
*entity-pool*
(symbol->string (-> part-tracker symbol))
(the-as pointer #x70004000)
)
)
(let ((t9-3 run-function-in-process)
(a0-8 s5-1)
(a1-6 part-tracker-init)
(a2-4 (-> *part-group-id-table* 141))
(a3-1 0)
(t0-0 #f)
(t1-0 #f)
(t2-0 #f)
(t3-0 *launch-matrix*)
)
(set! (-> t3-0 trans quad) (-> gp-0 quad))
((the-as (function object object object object object object object object none) t9-3)
a0-8
a1-6
a2-4
a3-1
t0-0
t1-0
t2-0
t3-0
)
)
(-> s5-1 ppointer)
)
)
)
0
(none)
)
;; WARN: Return type mismatch sound-id vs none.
(defmethod play-impact-sound metalhead-shot ((obj metalhead-shot) (arg0 projectile-options))
(with-pp
(case arg0
(((projectile-options lose-altitude proj-options-2))
(when (nonzero? (-> obj sound-id))
(when *sound-player-enable*
(let ((gp-0 (the-as sound-rpc-set-param (get-sound-buffer-entry))))
(set! (-> gp-0 command) (sound-command set-param))
(set! (-> gp-0 id) (-> obj sound-id))
(let ((a1-1 (-> obj root-override trans)))
(let ((s5-1 pp))
(when (= a1-1 #t)
(if (and s5-1 (type? s5-1 process-drawable) (nonzero? (-> (the-as process-drawable s5-1) root)))
(set! a1-1 (-> (the-as process-drawable s5-1) root trans))
(set! a1-1 (the-as vector #f))
)
)
)
(sound-trans-convert (the-as vector3w (-> gp-0 params trans)) a1-1)
)
(set! (-> gp-0 params mask) (the-as uint 32))
(-> gp-0 id)
)
)
)
)
)
(none)
)
)
(defun metalhead-shot-move ((arg0 metalhead-shot))
(projectile-move-fill-line-sphere arg0)
(let ((s5-0 (-> arg0 root-override)))
(let ((s4-0 (new 'stack-no-clear 'vector)))
(vector-! s4-0 (-> arg0 tail-pos) (-> s5-0 trans))
(let ((f0-0 (vector-length s4-0)))
(when (< 49152.0 f0-0)
(vector-normalize! s4-0 49152.0)
(vector+! (-> arg0 tail-pos) (-> s5-0 trans) s4-0)
)
)
)
(if (logtest? (-> s5-0 status) (collide-status touch-surface))
(go (method-of-object arg0 impact))
)
)
0
(none)
)
(defmethod init-proj-collision! metalhead-shot ((obj metalhead-shot))
"Init the [[projectile]]'s [[collide-shape]]"
(let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player))))
(set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> s5-0 reaction)
(the-as (function control-info collide-query vector vector collide-status) cshape-reaction-just-move)
)
(set! (-> s5-0 no-reaction)
(the-as (function collide-shape-moving collide-query vector vector object) nothing)
)
(set! (-> s5-0 penetrate-using) (penetrate enemy-yellow-shot))
(let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 2) 0)))
(set! (-> s5-0 total-prims) (the-as uint 3))
(set! (-> s4-0 prim-core collide-as) (collide-spec projectile))
(set! (-> s4-0 prim-core collide-with)
(collide-spec backgnd jak bot crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list)
)
(set! (-> s4-0 prim-core action) (collide-action solid))
(set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 819.2)
(set! (-> s5-0 root-prim) s4-0)
)
(let ((v1-13 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
(set! (-> v1-13 prim-core collide-as) (collide-spec projectile))
(set! (-> v1-13 prim-core collide-with)
(collide-spec backgnd jak bot crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list)
)
(set! (-> v1-13 prim-core action) (collide-action solid deadly))
(set-vector! (-> v1-13 local-sphere) 0.0 0.0 0.0 819.2)
)
(let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
(set! (-> v1-15 prim-core collide-as) (collide-spec projectile))
(set! (-> v1-15 prim-core collide-with)
(collide-spec jak bot crate civilian enemy vehicle-sphere hit-by-others-list player-list)
)
(set! (-> v1-15 prim-core action) (collide-action deadly))
(set-vector! (-> v1-15 local-sphere) 0.0 0.0 0.0 2457.6)
)
(set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
(let ((v1-18 (-> s5-0 root-prim)))
(set! (-> s5-0 backup-collide-as) (-> v1-18 prim-core collide-as))
(set! (-> s5-0 backup-collide-with) (-> v1-18 prim-core collide-with))
)
(set! (-> s5-0 max-iteration-count) (the-as uint 1))
(set! (-> s5-0 event-self) 'touched)
(set! (-> obj root-override) s5-0)
)
(set! (-> obj root-override pat-ignore-mask)
(new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1)
)
(none)
)
(defmethod init-proj-settings! metalhead-shot ((obj metalhead-shot))
"Init relevant settings for the [[projectile]] such as gravity, speed, timeout, etc"
(set! (-> obj tail-pos quad) (-> obj root-override trans quad))
(set! (-> obj attack-mode) 'metalhead-shot)
(set! (-> obj max-speed) 532480.0)
(set! (-> obj move) metalhead-shot-move)
(set! (-> obj timeout) (seconds 0.767))
(set-gravity-length (-> obj root-override dynam) 573440.0)
(none)
)
;; WARN: Return type mismatch (pointer process) vs (pointer metalhead-shot).
(defun spawn-metalhead-projectile ((arg0 metalhead-shot) (arg1 vector) (arg2 vector) (arg3 float))
(let ((gp-0 (new 'stack-no-clear 'projectile-init-by-other-params)))
(let ((v1-1 (vector-! (new 'stack-no-clear 'vector) arg2 arg1)))
(set! (-> gp-0 ent) (-> arg0 entity))
(set! (-> gp-0 charge) 1.0)
(set! (-> gp-0 options) (projectile-options))
(set! (-> gp-0 notify-handle) (process->handle arg0))
(set! (-> gp-0 owner-handle) (the-as handle #f))
(set! (-> gp-0 ignore-handle) (process->handle arg0))
(let* ((a0-10 *game-info*)
(a2-11 (+ (-> a0-10 attack-id) 1))
)
(set! (-> a0-10 attack-id) a2-11)
(set! (-> gp-0 attack-id) a2-11)
)
(set! (-> gp-0 timeout) (seconds 4))
(set! (-> gp-0 pos quad) (-> arg1 quad))
(vector-normalize-copy! (-> gp-0 vel) v1-1 arg3)
)
(the-as (pointer metalhead-shot) (spawn-projectile metalhead-shot gp-0 arg0 *default-dead-pool*))
)
)
(defpartgroup group-metalhead-grenade-shot
:id 143
:duration (seconds 0.5)
:flags (use-local-clock)
:bounds (static-bspherem 0 0 0 4)
:parts ((sp-item 637) (sp-item 638) (sp-item 639))
)
(defpart 637
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #xbb :page #xc))
(sp-flt spt-num 1.0)
(sp-rnd-flt spt-scale-x (meters 3) (meters 1) 1.0)
(sp-flt spt-rot-x 409.6)
(sp-copy-from-other spt-scale-y -4)
(sp-flt spt-r 255.0)
(sp-flt spt-g 255.0)
(sp-flt spt-b 255.0)
(sp-flt spt-a 64.0)
(sp-flt spt-fade-r -5.5)
(sp-flt spt-fade-g -51.0)
(sp-flt spt-fade-b -5.5)
(sp-flt spt-fade-a -8.533334)
(sp-int spt-timer 5)
(sp-cpuinfo-flags sp-cpuinfo-flag-0 sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14 glow)
(sp-flt spt-userdata 409.6)
)
)
(defpart 638
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x1 :page #xade))
(sp-flt spt-num 4.0)
(sp-rnd-flt spt-scale-x (meters 1) (meters 0.2) 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-flt spt-r 255.0)
(sp-flt spt-g 255.0)
(sp-flt spt-b 255.0)
(sp-flt spt-a 128.0)
(sp-flt spt-scalevel-x (meters -0.01))
(sp-rnd-flt spt-rotvel-z (degrees -1.2) (degrees 1.2) 1.0)
(sp-copy-from-other spt-scalevel-y -4)
(sp-flt spt-fade-r -1.375)
(sp-flt spt-fade-g -6.375)
(sp-flt spt-fade-b -1.375)
(sp-rnd-flt spt-fade-a -3.2 -3.2 1.0)
(sp-int spt-timer 40)
(sp-cpuinfo-flags sp-cpuinfo-flag-0 sp-cpuinfo-flag-2 sp-cpuinfo-flag-3 sp-cpuinfo-flag-14)
(sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 360.0) 1.0)
(sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
(sp-rnd-flt spt-conerot-radius (meters 0) (meters 0.2) 1.0)
)
)
(defpart 639
:init-specs ((sp-tex spt-texture (new 'static 'texture-id :index #x1 :page #xade))
(sp-rnd-flt spt-num 2.0 1.0 1.0)
(sp-rnd-flt spt-scale-x (meters 0.8) (meters 0.4) 1.0)
(sp-rnd-flt spt-scale-y (meters 0.6) (meters 0.2) 1.0)
(sp-flt spt-r 255.0)
(sp-flt spt-g 255.0)
(sp-flt spt-b 255.0)
(sp-rnd-flt spt-a 64.0 32.0 1.0)
(sp-rnd-flt spt-scalevel-x (meters -0.0026666666) (meters -0.0026666666) 1.0)
(sp-copy-from-other spt-scalevel-y -4)
(sp-flt spt-fade-r -0.73333335)
(sp-flt spt-fade-g -3.4)
(sp-flt spt-fade-b -0.73333335)
(sp-rnd-flt spt-accel-y -1.3653333 -4.096 1.0)
(sp-int spt-timer 300)
(sp-cpuinfo-flags sp-cpuinfo-flag-0 sp-cpuinfo-flag-2 sp-cpuinfo-flag-14)
(sp-int spt-next-time 75)
(sp-launcher-by-id spt-next-launcher 640)
(sp-rnd-flt spt-conerot-x (degrees 0.0) (degrees 360.0) 1.0)
(sp-rnd-flt spt-conerot-y (degrees 0.0) (degrees 360.0) 1.0)
(sp-rnd-flt spt-conerot-radius (meters 0) (meters 0.35) 1.0)
)
)
(defpart 640
:init-specs ((sp-flt spt-fade-r 0.0)
(sp-flt spt-fade-g 0.0)
(sp-flt spt-fade-b 0.0)
(sp-rnd-flt spt-fade-a -0.48 -0.48 1.0)
)
)
(deftype metalhead-grenade-shot (projectile)
((tumble-quat quaternion :inline :offset-assert 480)
(blast-radius float :offset-assert 496)
)
:heap-base #x180
:method-count-assert 40
:size-assert #x1f4
:flag-assert #x28018001f4
)
(defmethod spawn-shell-particles metalhead-grenade-shot ((obj metalhead-grenade-shot))
"TODO - confirm"
(let ((gp-0 (get-process *default-dead-pool* part-tracker #x4000)))
(when gp-0
(let ((t9-1 (method-of-type part-tracker activate)))
(t9-1 (the-as part-tracker gp-0) obj (symbol->string (-> part-tracker symbol)) (the-as pointer #x70004000))
)
(let ((t9-2 run-function-in-process)
(a0-3 gp-0)
(a1-2 part-tracker-init)
(a2-4 (-> *part-group-id-table* 76))
(a3-1 0)
(t0-0 #f)
(t1-0 #f)
(t2-0 #f)
(t3-0 *launch-matrix*)
)
(set! (-> t3-0 trans quad) (-> obj root-override trans quad))
((the-as (function object object object object object object object object none) t9-2)
a0-3
a1-2
a2-4
a3-1
t0-0
t1-0
t2-0
t3-0
)
)
(-> gp-0 ppointer)
)
)
0
(none)
)
(defmethod play-impact-sound metalhead-grenade-shot ((obj metalhead-grenade-shot) (arg0 projectile-options))
(case arg0
(((projectile-options lose-altitude))
(sound-play "gren-shot-hit")
)
(((projectile-options lose-altitude proj-options-2))
(sound-play "gren-missile" :id (-> obj sound-id) :position (-> obj root-override trans))
)
)
0
(none)
)
(defstate impact (metalhead-grenade-shot)
:virtual #t
:event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block))
(case event-type
(('touched)
(let* ((s4-0 proc)
(v1-1 (if (type? s4-0 process-drawable)
(the-as process-drawable s4-0)
)
)
)
(when v1-1
(let ((s4-1 (-> v1-1 root))
(a1-3 (new 'stack 'collide-query))
)
0.0
(set! (-> a1-3 start-pos quad) (-> self root-override root-prim prim-core world-sphere quad))
(vector-!
(-> a1-3 move-dist)
(the-as vector (-> (the-as collide-shape s4-1) root-prim prim-core))
(-> a1-3 start-pos)
)
(let ((v1-6 a1-3))
(set! (-> v1-6 radius) 40.96)
(set! (-> v1-6 collide-with) (collide-spec backgnd))
(set! (-> v1-6 ignore-process0) self)
(set! (-> v1-6 ignore-process1) (ppointer->process (-> self parent)))
(set! (-> v1-6 ignore-pat) (-> self root-override pat-ignore-mask))
(set! (-> v1-6 action-mask) (collide-action solid))
)
(when (< (fill-and-probe-using-line-sphere *collide-cache* a1-3) 0.0)
(let ((a1-4 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-4 from) (process->ppointer self))
(set! (-> a1-4 num-params) 2)
(set! (-> a1-4 message) 'attack)
(set! (-> a1-4 param 0) (-> event param 0))
(let ((v1-13 (new 'static 'attack-info :mask (attack-info-mask mode id))))
(set! (-> v1-13 id) (-> self attack-id))
(set! (-> v1-13 mode) 'explode)
(set! (-> a1-4 param 1) (the-as uint v1-13))
)
(send-event-function proc a1-4)
)
(let ((v1-15 (-> self notify-handle)))
(if (handle->process v1-15)
(send-event (-> v1-15 process 0) 'notify 'attack proc)
)
)
)
)
)
)
)
)
)
:code (behavior ()
(let ((v1-1 (-> self root-override root-prim)))
(set! (-> v1-1 local-sphere w) (-> self blast-radius))
(set! (-> v1-1 prim-core world-sphere w) (-> self blast-radius))
(set! (-> v1-1 prim-core collide-with)
(collide-spec jak crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list)
)
(set! (-> v1-1 prim-core collide-as) (collide-spec enemy))
)
(update-transforms (-> self root-override))
(let ((a1-0 (new 'stack-no-clear 'overlaps-others-params)))
(set! (-> a1-0 options) (overlaps-others-options))
(set! (-> a1-0 collide-with-filter) (the-as collide-spec -1))
(set! (-> a1-0 tlist) *touching-list*)
(find-overlapping-shapes (-> self root-override) a1-0)
)
(suspend)
(let ((v1-9 (-> self root-override root-prim)))
(set! (-> v1-9 prim-core collide-as) (collide-spec))
(set! (-> v1-9 prim-core collide-with) (collide-spec))
)
0
(while (-> self child)
(suspend)
)
(deactivate self)
(none)
)
)
(defstate dissipate (metalhead-grenade-shot)
:virtual #t
:enter (behavior ()
(go-virtual impact)
(none)
)
)
(defmethod spawn-impact-particles metalhead-grenade-shot ((obj metalhead-grenade-shot))
"Spawns associated particles with the projectile if applicable"
(spawn (-> obj part) (-> obj root-override trans))
0
(none)
)
(defun gren-canister-move ((arg0 metalhead-grenade-shot))
(quaternion*! (-> arg0 root-override quat) (-> arg0 root-override quat) (-> arg0 tumble-quat))
(projectile-move-fill-all-dirs arg0)
(let ((s5-0 (new 'stack-no-clear 'water-info)))
(water-info-init! (-> arg0 root-override) s5-0 (collide-action solid semi-solid))
(if (and (logtest? (-> s5-0 flags) (water-flags active)) (< (-> arg0 root-override trans y) (-> s5-0 trans y)))
(go (method-of-object arg0 impact))
)
)
(if (logtest? (-> arg0 root-override status) (collide-status touch-surface))
(go (method-of-object arg0 impact))
)
0
(none)
)
(defun gren-cshape-reaction-canister ((arg0 collide-shape-moving) (arg1 metalhead-grenade-shot))
(let ((s5-0 0))
(let ((a1-1 (new 'stack-no-clear 'vector)))
(vector-float*! a1-1 (the-as vector (&-> arg1 starting-dir y)) (the-as float (-> arg1 connection-list prev0)))
(move-by-vector! arg0 a1-1)
)
(let ((f30-0 (vector-dot (-> arg0 transv) (the-as vector (&-> arg1 next-state))))
(s3-0 (new 'stack-no-clear 'vector))
)
(vector-float*! s3-0 (the-as vector (&-> arg1 next-state)) (* f30-0 (rand-vu-float-range 1.6 2.2)))
(vector-! (-> arg0 transv) (-> arg0 transv) s3-0)
)
(let ((v0-2 (logior s5-0 7)))
(logior! (-> arg0 status) v0-2)
)
)
(vector-float*! (-> arg0 transv) (-> arg0 transv) 0.88)
(none)
)
(defmethod init-proj-collision! metalhead-grenade-shot ((obj metalhead-grenade-shot))
"Init the [[projectile]]'s [[collide-shape]]"
(let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player))))
(set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> s5-0 reaction)
(the-as (function control-info collide-query vector vector collide-status) gren-cshape-reaction-canister)
)
(set! (-> s5-0 no-reaction)
(the-as (function collide-shape-moving collide-query vector vector object) nothing)
)
(set! (-> s5-0 penetrate-using) (penetrate enemy-dark-shot))
(let ((v1-7 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
(set! (-> v1-7 prim-core collide-as) (collide-spec projectile))
(set! (-> v1-7 prim-core collide-with)
(collide-spec backgnd jak crate obstacle hit-by-others-list player-list pusher)
)
(set! (-> v1-7 prim-core action) (collide-action solid))
(set-vector! (-> v1-7 local-sphere) 0.0 0.0 0.0 1228.8)
(set! (-> s5-0 total-prims) (the-as uint 1))
(set! (-> s5-0 root-prim) v1-7)
)
(set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
(let ((v1-10 (-> s5-0 root-prim)))
(set! (-> s5-0 backup-collide-as) (-> v1-10 prim-core collide-as))
(set! (-> s5-0 backup-collide-with) (-> v1-10 prim-core collide-with))
)
(set! (-> s5-0 max-iteration-count) (the-as uint 2))
(set! (-> s5-0 event-self) 'touched)
(set! (-> obj root-override) s5-0)
)
(set! (-> obj root-override pat-ignore-mask)
(new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1)
)
(none)
)
;; WARN: Return type mismatch sound-id vs none.
(defmethod init-proj-settings! metalhead-grenade-shot ((obj metalhead-grenade-shot))
"Init relevant settings for the [[projectile]] such as gravity, speed, timeout, etc"
(set! (-> obj attack-mode) 'eco-yellow)
(set! (-> obj blast-radius) 4096.0)
(set! (-> obj max-speed) 135168.0)
(set! (-> obj timeout) (seconds 4))
(set! (-> obj update-velocity) projectile-update-velocity-add-gravity)
(set! (-> obj move) gren-canister-move)
(set! (-> obj root-override dynam gravity y) 102400.0)
(set! (-> obj root-override dynam gravity-length) 102400.0)
(set! (-> obj root-override dynam gravity-max) 102400.0)
(let ((f0-5 1092.2667))
(quaternion-axis-angle! (-> obj tumble-quat) 1.0 0.0 0.0 f0-5)
)
(set! (-> obj part) (create-launch-control (-> *part-group-id-table* 143) obj))
(set! (-> obj sound-id) (new-sound-id))
(none)
)
;; WARN: Return type mismatch (pointer process) vs (pointer metalhead-grenade-shot).
(defun spawn-metalhead-grenade ((arg0 metalhead-grenade-shot) (arg1 vector) (arg2 vector) (arg3 float))
(let ((gp-0 (new 'stack-no-clear 'projectile-init-by-other-params)))
(let ((v1-1 (vector-! (new 'stack-no-clear 'vector) arg2 arg1)))
(set! (-> gp-0 ent) (-> arg0 entity))
(set! (-> gp-0 charge) 1.0)
(set! (-> gp-0 options) (projectile-options))
(set! (-> gp-0 notify-handle) (process->handle arg0))
(set! (-> gp-0 owner-handle) (the-as handle #f))
(set! (-> gp-0 ignore-handle) (process->handle arg0))
(let* ((a0-10 *game-info*)
(a2-11 (+ (-> a0-10 attack-id) 1))
)
(set! (-> a0-10 attack-id) a2-11)
(set! (-> gp-0 attack-id) a2-11)
)
(set! (-> gp-0 timeout) (seconds 4))
(set! (-> gp-0 pos quad) (-> arg1 quad))
(vector-normalize-copy! (-> gp-0 vel) v1-1 arg3)
)
(the-as (pointer metalhead-grenade-shot) (spawn-projectile metalhead-shot gp-0 arg0 *default-dead-pool*))
)
)