jak-project/goal_src/jak2/engine/target/gun/gun-blue-shot.gc

320 lines
12 KiB
Common Lisp
Raw Normal View History

;;-*-Lisp-*-
(in-package goal)
;; name: gun-blue-shot.gc
;; name in dgo: gun-blue-shot
;; dgos: ENGINE, GAME
;; DECOMP BEGINS
(defbehavior target-gun-fire-blue target ()
(let ((gp-0 (-> self gun))
(s4-0 (-> self gun fire-dir-out))
(s5-0 (new 'stack-no-clear 'vector))
)
(let ((s3-0 (new 'stack-no-clear 'quaternion)))
(quaternion-vector-angle! s3-0 s4-0 (* 182.04445 (rand-vu-float-range 0.0 360.0)))
(vector-rotate-y! s5-0 s4-0 (* 182.04445 (rand-vu-float-range 0.0 1.1)))
(vector-orient-by-quat! s5-0 s5-0 s3-0)
)
(let ((s4-1 (new 'stack-no-clear 'projectile-init-by-other-params)))
(set! (-> s4-1 ent) (-> self entity))
(set! (-> s4-1 charge) 1.0)
(set! (-> s4-1 options) (projectile-options account-for-target-velocity deal-damage proj-options-8000))
(set! (-> s4-1 pos quad) (-> gp-0 fire-point quad))
(set! (-> s4-1 vel quad) (-> s5-0 quad))
(set! (-> s4-1 notify-handle) (the-as handle #f))
(set! (-> s4-1 owner-handle) (the-as handle #f))
(set! (-> s4-1 ignore-handle) (process->handle (the-as process (send-event self 'get-vehicle))))
(let* ((v1-13 *game-info*)
(a0-15 (+ (-> v1-13 attack-id) 1))
)
(set! (-> v1-13 attack-id) a0-15)
(set! (-> s4-1 attack-id) a0-15)
)
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
(set! (-> s4-1 timeout) (seconds 4))
(spawn-projectile gun-blue-shot s4-1 (ppointer->process (-> gp-0 gun)) *default-dead-pool*)
)
)
)
(deftype gun-blue-shot (projectile)
((init-pos vector :inline :offset-assert 480)
(init-dir vector :inline :offset-assert 496)
(collide-normal vector :inline :offset-assert 512)
)
:heap-base #x190
:method-count-assert 40
:size-assert #x210
:flag-assert #x2801900210
)
(defmethod draw-laser-sight gun-blue-shot ((this gun-blue-shot))
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
"TODO - confirm If applicable, draw the laser sight particles"
(let* ((s5-0 (ppointer->process (-> this parent)))
(s4-0 (-> *part-id-table* 196))
(s3-0 (get-field-spec-by-id s4-0 (sp-field-id spt-omega)))
(s5-1 (vector<-cspace! (new 'stack-no-clear 'vector) (-> (the-as projectile s5-0) node-list data 16)))
)
(when s3-0
(let ((s1-0 (vector-normalize-copy! (new 'stack-no-clear 'vector) (-> this starting-dir) 1.0))
(s2-0 (new 'stack-no-clear 'collide-query))
)
(vector-rotate-y! s1-0 s1-0 16384.0)
(vector+float*! s1-0 s5-1 s1-0 -8806.4)
(set! (-> s2-0 start-pos quad) (-> s1-0 quad))
(vector-float*! (-> s2-0 move-dist) (-> this root dynam gravity-normal) -81920.0)
(let ((v1-11 s2-0))
(set! (-> v1-11 radius) 1228.8)
(set! (-> v1-11 collide-with) (collide-spec backgnd obstacle hit-by-player-list hit-by-others-list))
(set! (-> v1-11 ignore-process0) this)
(set! (-> v1-11 ignore-process1) (ppointer->process (-> this parent)))
(set! (-> v1-11 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1))
(set! (-> v1-11 action-mask) (collide-action solid))
)
(if (>= (fill-and-probe-using-line-sphere *collide-cache* s2-0) 0.0)
(set! (-> s3-0 initial-valuef)
(fmin (+ 1638.4 (-> s2-0 best-other-tri intersect y)) (+ -1228.8 (-> this starting-pos y)))
)
(set! (-> s3-0 initial-valuef) (+ -81920.0 (-> this starting-pos y)))
)
)
)
(let ((s4-1 (get-field-spec-by-id s4-0 (sp-field-id spt-rotate-y))))
(if s4-1
(set! (-> s4-1 initial-valuef) (y-angle (-> this root)))
)
)
(launch-particles (-> *part-id-table* 196) s5-1)
(let ((s4-2 (get-field-spec-by-id (-> *part-id-table* 195) (sp-field-id spt-rotate-y))))
(if s4-2
(set! (-> s4-2 initial-valuef) (y-angle (-> this root)))
)
)
(launch-particles (-> *part-id-table* 195) s5-1)
)
0
(none)
)
(defmethod spawn-shell-particles gun-blue-shot ((this gun-blue-shot))
"TODO - confirm"
(rlet ((vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
)
(init-vf0-vector)
(let ((s3-1 (vector-! (new 'stack-no-clear 'vector) (-> this root trans) (-> this init-pos))))
(draw-beam (-> *part-id-table* 191) (-> this init-pos) s3-1 #t #t)
(draw-beam (-> *part-id-table* 194) (-> this init-pos) (-> this starting-dir) #f #t)
(let ((s5-0 (-> *part-id-table* 206))
(s4-0 (-> *part-id-table* 205))
)
(new 'stack-no-clear 'vector)
(let ((s2-0 (vector-reflect! (new 'stack-no-clear 'vector) s3-1 (-> this collide-normal))))
(vector-normalize! s2-0 1.0)
(get-field-spec-by-id s5-0 (sp-field-id spt-conerot-x))
(get-field-spec-by-id s5-0 (sp-field-id spt-conerot-y))
(get-field-spec-by-id s5-0 (sp-field-id spt-conerot-z))
(let ((a1-7 (new 'stack-no-clear 'matrix))
(s1-0 (new 'stack-no-clear 'vector))
(s3-2 (new 'stack-no-clear 'vector))
)
(vector-cross! (the-as vector (-> a1-7 vector)) *y-vector* s2-0)
(vector-cross! (-> a1-7 vector 1) s2-0 (the-as vector (-> a1-7 vector)))
(set! (-> a1-7 vector 2 quad) (-> s2-0 quad))
(matrix->eul (the-as euler-angles s1-0) a1-7 21)
(vector-negate! s3-2 s1-0)
(let ((a0-14 s3-2))
(let ((v1-16 s3-2))
(let ((a1-10 -3640.889))
(.mov vf6 a1-10)
)
(.lvf vf4 (&-> v1-16 quad))
)
(.add.x.vf vf5 vf0 vf0 :mask #b1000)
(.add.x.vf vf5 vf4 vf6 :mask #b111)
(.svf (&-> a0-14 quad) vf5)
)
(sparticle-set-conerot s5-0 s3-2)
(sparticle-set-conerot s4-0 s3-2)
)
)
)
)
(let ((s5-1 (get-process *default-dead-pool* part-tracker #x4000)))
(when s5-1
(let ((t9-12 (method-of-type part-tracker activate)))
(t9-12
(the-as part-tracker s5-1)
*entity-pool*
(symbol->string (-> part-tracker symbol))
(the-as pointer #x70004000)
)
)
(let ((t9-13 run-function-in-process)
(a0-19 s5-1)
(a1-15 part-tracker-init)
(a2-12 (-> *part-group-id-table* 68))
(a3-3 0)
(t0-2 #f)
(t1-0 #f)
(t2-0 #f)
(t3-0 *launch-matrix*)
)
(set! (-> t3-0 trans quad) (-> this root trans quad))
((the-as (function object object object object object object object object none) t9-13)
a0-19
a1-15
a2-12
a3-3
t0-2
t1-0
t2-0
t3-0
)
)
(-> s5-1 ppointer)
)
)
0
(none)
)
)
(defmethod unknown-particles gun-blue-shot ((this gun-blue-shot))
"TODO - confirm"
(draw-beam (-> *part-id-table* 191) (-> this init-pos) (-> this init-dir) #f #t)
(draw-beam (-> *part-id-table* 194) (-> this init-pos) (-> this starting-dir) #f #t)
0
(none)
)
;; WARN: Return type mismatch sound-id vs none.
(defmethod play-impact-sound gun-blue-shot ((this gun-blue-shot) (arg0 projectile-options))
(let ((v1-0 arg0))
(cond
((zero? v1-0)
(sound-play "blue-shot-fire")
)
((= v1-0 (projectile-options lose-altitude))
(sound-play "blue-shot-hit")
)
)
)
(none)
)
(defmethod made-impact? gun-blue-shot ((this gun-blue-shot))
"TODO - queries the collision cache, return true/false"
(let ((v1-0 (-> this root))
(t1-0 (new 'stack-no-clear 'collide-query))
)
(let ((a1-0 t1-0))
(set! (-> a1-0 radius) (-> v1-0 root-prim prim-core world-sphere w))
(set! (-> a1-0 collide-with) (-> v1-0 root-prim prim-core collide-with))
(set! (-> a1-0 ignore-process0) this)
(set! (-> a1-0 ignore-process1) (ppointer->process (-> this parent)))
(set! (-> a1-0 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1))
(set! (-> a1-0 action-mask) (collide-action solid))
)
(fill-and-try-snap-to-surface v1-0 (-> v1-0 transv) -12288.0 12697.6 -2048.0 t1-0)
)
)
(defun gun-blue-shot-move ((arg0 gun-blue-shot))
(projectile-move-fill-line-sphere arg0)
(if (logtest? (-> arg0 root status) (collide-status touch-surface))
(go (method-of-object arg0 impact))
)
0
(none)
)
;; WARN: Return type mismatch int vs collide-status.
(defun cshape-reaction-blue-shot ((arg0 control-info) (arg1 collide-query) (arg2 vector) (arg3 vector))
(vector-reset! arg2)
(let ((a1-1 (new 'stack-no-clear 'vector)))
(vector-float*! a1-1 (-> arg1 move-dist) (-> arg1 best-dist))
(move-by-vector! arg0 a1-1)
)
(set! (-> (the-as gun-blue-shot (-> arg0 process)) collide-normal quad) (-> arg1 best-other-tri normal quad))
(let ((v0-1 4))
(logior! (-> arg0 status) v0-1)
(the-as collide-status v0-1)
)
)
(defmethod init-proj-collision! gun-blue-shot ((this gun-blue-shot))
"Init the [[projectile]]'s [[collide-shape]]"
(let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum hit-by-player))))
(set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> s5-0 reaction) cshape-reaction-blue-shot)
(set! (-> s5-0 no-reaction)
(the-as (function collide-shape-moving collide-query vector vector object) nothing)
)
(set! (-> s5-0 penetrate-using) (penetrate jak-blue-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 bot crate civilian enemy obstacle vehicle-sphere hit-by-others-list player-list pusher)
)
(set! (-> s4-0 prim-core action) (collide-action solid))
(set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 1228.8)
(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 obstacle pusher))
(set! (-> v1-13 prim-core action) (collide-action solid))
(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 bot crate civilian enemy vehicle-sphere hit-by-others-list player-list)
)
(set! (-> v1-15 prim-core action) (collide-action solid))
(set-vector! (-> v1-15 local-sphere) 0.0 0.0 0.0 4096.0)
)
(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! (-> this root) s5-0)
)
(set! (-> this root pat-ignore-mask)
(new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1)
)
0
(none)
)
(defmethod init-proj-settings! gun-blue-shot ((this gun-blue-shot))
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
"Init relevant settings for the [[projectile]] such as gravity, speed, timeout, etc"
(with-pp
(cpad-set-buzz! (-> *cpad-list* cpads 0) 1 204 (seconds 0.1))
(set! (-> this init-pos quad) (-> this root trans quad))
(set! (-> this init-dir quad) (-> this starting-dir quad))
(vector-normalize-copy! (-> this root transv) (-> this init-dir) (* 327680.0 (-> pp clock frames-per-second)))
(set! (-> this attack-mode) 'eco-blue)
(set! (-> this max-speed) (* 327680.0 (-> pp clock frames-per-second)))
(set! (-> this timeout) 1)
(set! (-> this move) gun-blue-shot-move)
(vector-reset! (-> this collide-normal))
(set! (-> this damage) (if (logtest? (game-feature gun-upgrade-damage) (-> *game-info* features))
4.0
2.0
)
)
0
(none)
)
)