jak-project/goal_src/levels/jungle/hopper.gc
ManDude 25b0e1be7d
[decomp] collectables + works ingame! (#971)
* decomp: `collectables`

* fix types

* `powerups` and fixes

* fixes

* Merge branch 'pr/929' into d/temp/collectables

* fix collide stuff

* update things...

* update

* update

* temp bump global heap mem

* fix `defstate` hooks wrong/unnecessary sets & collide stuff for collectables

* dumb mistakes :)

* stub out broken process-drawable stuff

* update refs

* add `:no-inspect` key and save some memory & remove birth logs

* Update kmachine.h

* clang

* add citadel

* fix no-inspect key

* fix tests!!

* fix stupid mistake in `collide-shape-prim-sphere` alloc

* comment annoying print

* feedback

* fix edge-case probably

* remove `:no-inspect`s
2021-11-23 18:25:57 -05:00

703 lines
17 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: hopper.gc
;; name in dgo: hopper
;; dgos: JUN, JUNGLE, L1
;; DECOMP BEGINS
(deftype hopper (nav-enemy)
((jump-length float :offset-assert 400)
(shadow-min-y float :offset-assert 404)
)
:heap-base #x130
:method-count-assert 76
:size-assert #x198
:flag-assert #x4c01300198
)
(defskelgroup *hopper-sg* hopper
0
5
((1 (meters 20)) (2 (meters 40)) (3 (meters 999999)))
:bounds (static-spherem 0 0 0 3)
:longest-edge (meters 1)
:shadow 4
)
nav-enemy-default-event-handler
(defmethod common-post hopper ((obj hopper))
(let ((v1-1 (-> obj draw shadow-ctrl)))
(set!
(-> v1-1 settings bot-plane w)
(- (- (-> obj shadow-min-y) (-> obj collide-info trans y)))
)
)
0
((the-as (function nav-enemy none) (find-parent-method hopper 39)) obj)
0
(none)
)
(defbehavior hopper-find-ground hopper ((arg0 vector))
(let ((s5-0 (new 'stack-no-clear 'vector)))
(let ((t1-0 (new 'stack-no-clear 'collide-tri-result))
(f30-0 61440.0)
)
(set! (-> s5-0 quad) (-> arg0 quad))
(set! (-> s5-0 y) (+ 20480.0 (-> s5-0 y)))
(let
((f0-2
(fill-and-probe-using-y-probe
*collide-cache*
s5-0
f30-0
(the-as uint 1)
self
t1-0
(the-as uint 1)
)
)
)
(if (< f0-2 0.0)
(return (the-as object #f))
)
(set! (-> s5-0 y) (- (-> s5-0 y) (* f0-2 f30-0)))
)
)
(set! (-> arg0 quad) (-> s5-0 quad))
)
0
)
(defbehavior hopper-jump-to hopper ((arg0 vector))
(set! (-> self jump-dest quad) (-> arg0 quad))
(hopper-find-ground (-> self jump-dest))
(set!
(-> self shadow-min-y)
(+
(fmin (-> self collide-info trans y) (-> self jump-dest y))
(-> self nav-info shadow-min-y)
)
)
(nav-enemy-initialize-custom-jump
(-> self jump-dest)
#f
(-> self nav-info jump-height-min)
(-> self nav-info jump-height-factor)
-409600.0
)
(set! (-> self nav-enemy-flags) (logand -513 (-> self nav-enemy-flags)))
(set! (-> self nav-enemy-flags) (logand -1025 (-> self nav-enemy-flags)))
(logior! (-> self nav-enemy-flags) 16)
(set! (-> self nav-enemy-flags) (logand -9 (-> self nav-enemy-flags)))
(when (not (nav-enemy-facing-point? (-> self jump-dest) 5461.3335))
(ja-channel-push! 1 60)
(nav-enemy-turn-to-face-point (-> self jump-dest) 1820.4445)
)
(set! (-> self nav-enemy-flags) (logand -17 (-> self nav-enemy-flags)))
(nav-enemy-execute-jump)
(set!
(-> self shadow-min-y)
(+ (-> self collide-info trans y) (-> self nav-info shadow-min-y))
)
(set! (-> self nav-enemy-flags) (logand -9 (-> self nav-enemy-flags)))
(nav-enemy-jump-land-anim)
0
(none)
)
(defbehavior hopper-do-jump hopper ()
(dummy-11 (-> self nav) (-> self nav target-pos))
(if (< (-> self jump-length) (vector-length (-> self nav travel)))
(vector-normalize! (-> self nav travel) (-> self jump-length))
)
(vector+!
(-> self jump-dest)
(-> self collide-info trans)
(-> self nav travel)
)
(hopper-jump-to (-> self jump-dest))
0
(none)
)
(defstate nav-enemy-idle (hopper)
:virtual #t
:event
(the-as
(function process int symbol event-message-block object :behavior hopper)
nav-enemy-default-event-handler
)
:code
(behavior ()
(ja-channel-push! 1 22)
(while #t
(dotimes (gp-0 3)
(let ((a0-1 (-> self skel root-channel 0)))
(set!
(-> a0-1 frame-group)
(the-as art-joint-anim (-> self draw art-group data 5))
)
(set!
(-> a0-1 param 0)
(the
float
(+
(->
(the-as art-joint-anim (-> self draw art-group data 5))
data
0
length
)
-1
)
)
)
(set! (-> a0-1 param 1) 1.0)
(set! (-> a0-1 frame-num) 0.0)
(joint-control-channel-group!
a0-1
(the-as art-joint-anim (-> self draw art-group data 5))
num-func-seek!
)
)
(until (ja-done? 0)
(suspend)
(let ((a0-2 (-> self skel root-channel 0)))
(set!
(-> a0-2 param 0)
(the float (+ (-> a0-2 frame-group data 0 length) -1))
)
(set! (-> a0-2 param 1) 1.0)
(joint-control-channel-group-eval!
a0-2
(the-as art-joint-anim #f)
num-func-seek!
)
)
)
)
(let ((a0-4 (-> self skel root-channel 0)))
(set!
(-> a0-4 frame-group)
(the-as art-joint-anim (-> self draw art-group data 6))
)
(set!
(-> a0-4 param 0)
(the
float
(+
(->
(the-as art-joint-anim (-> self draw art-group data 6))
data
0
length
)
-1
)
)
)
(set! (-> a0-4 param 1) 1.0)
(set! (-> a0-4 frame-num) 0.0)
(joint-control-channel-group!
a0-4
(the-as art-joint-anim (-> self draw art-group data 6))
num-func-seek!
)
)
(until (ja-done? 0)
(suspend)
(let ((a0-5 (-> self skel root-channel 0)))
(set!
(-> a0-5 param 0)
(the float (+ (-> a0-5 frame-group data 0 length) -1))
)
(set! (-> a0-5 param 1) 1.0)
(joint-control-channel-group-eval!
a0-5
(the-as art-joint-anim #f)
num-func-seek!
)
)
)
)
(none)
)
)
(defstate nav-enemy-patrol (hopper)
:virtual #t
:event
(the-as
(function process int symbol event-message-block object :behavior hopper)
nav-enemy-jump-event-handler
)
:trans
(behavior ()
(if (zero? (logand (-> self nav-enemy-flags) 8))
((-> (method-of-type nav-enemy nav-enemy-patrol) trans))
)
(none)
)
:code
(behavior ()
(vector-reset! (-> self collide-info transv))
(set! (-> self jump-length) 16384.0)
(set! (-> self nav-enemy-flags) (logand -9 (-> self nav-enemy-flags)))
(while #t
(cond
((= (if (> (-> self skel active-channels) 0)
(-> self skel root-channel 0 frame-group)
)
(-> self draw art-group data 7)
)
(ja-channel-push! 1 20)
(let ((a0-6 (-> self skel root-channel 0)))
(set!
(-> a0-6 frame-group)
(the-as art-joint-anim (-> self draw art-group data 8))
)
(set!
(-> a0-6 param 0)
(the
float
(+
(->
(the-as art-joint-anim (-> self draw art-group data 8))
data
0
length
)
-1
)
)
)
(set! (-> a0-6 param 1) 1.0)
(set! (-> a0-6 frame-num) 0.0)
(joint-control-channel-group!
a0-6
(the-as art-joint-anim (-> self draw art-group data 8))
num-func-seek!
)
)
(until (ja-done? 0)
(suspend)
(let ((a0-7 (-> self skel root-channel 0)))
(set!
(-> a0-7 param 0)
(the float (+ (-> a0-7 frame-group data 0 length) -1))
)
(set! (-> a0-7 param 1) 1.0)
(joint-control-channel-group-eval!
a0-7
(the-as art-joint-anim #f)
num-func-seek!
)
)
)
(ja-channel-push! 1 30)
)
((= (if (> (-> self skel active-channels) 0)
(-> self skel root-channel 0 frame-group)
)
(-> self draw art-group data 9)
)
(ja-channel-push! 1 30)
(let ((a0-15 (-> self skel root-channel 0)))
(set!
(-> a0-15 frame-group)
(the-as art-joint-anim (-> self draw art-group data 10))
)
(set!
(-> a0-15 param 0)
(the
float
(+
(->
(the-as art-joint-anim (-> self draw art-group data 10))
data
0
length
)
-1
)
)
)
(set! (-> a0-15 param 1) 1.0)
(set! (-> a0-15 frame-num) 0.0)
(joint-control-channel-group!
a0-15
(the-as art-joint-anim (-> self draw art-group data 10))
num-func-seek!
)
)
(until (ja-done? 0)
(suspend)
(let ((a0-16 (-> self skel root-channel 0)))
(set!
(-> a0-16 param 0)
(the float (+ (-> a0-16 frame-group data 0 length) -1))
)
(set! (-> a0-16 param 1) 1.0)
(joint-control-channel-group-eval!
a0-16
(the-as art-joint-anim #f)
num-func-seek!
)
)
)
(ja-channel-push! 1 30)
)
(else
(ja-channel-push! 1 22)
)
)
(set! (-> self state-time) (-> *display* base-frame-counter))
(let ((gp-0 (-> self skel root-channel 0)))
(joint-control-channel-group-eval!
gp-0
(the-as art-joint-anim (-> self draw art-group data 5))
num-func-identity
)
(set! (-> gp-0 frame-num) 0.0)
)
(until (>= (- (-> *display* base-frame-counter) (-> self state-time)) 150)
(suspend)
(let ((a0-21 (-> self skel root-channel 0)))
(set! (-> a0-21 param 0) 1.0)
(joint-control-channel-group-eval!
a0-21
(the-as art-joint-anim #f)
num-func-loop!
)
)
)
(when
(or
(logtest? (nav-control-flags bit19) (-> self nav flags))
(< 2.0 (-> self nav block-count))
)
(set! (-> self nav block-count) 0.0)
(logior! (-> self nav flags) (nav-control-flags bit10))
(nav-enemy-get-new-patrol-point)
(set! (-> self nav target-pos quad) (-> self nav destination-pos quad))
)
(hopper-do-jump)
)
(none)
)
:post
(the-as (function none :behavior hopper) nav-enemy-jump-post)
)
(defstate nav-enemy-notice (hopper)
:virtual #t
:event
(the-as
(function process int symbol event-message-block object :behavior hopper)
nav-enemy-default-event-handler
)
:code
(behavior ()
(go-virtual nav-enemy-chase)
(none)
)
)
(defstate nav-enemy-chase (hopper)
:virtual #t
:event
(the-as
(function process int symbol event-message-block object :behavior hopper)
nav-enemy-jump-event-handler
)
:trans
(behavior ()
(if (zero? (logand (-> self nav-enemy-flags) 8))
((-> (method-of-type nav-enemy nav-enemy-chase) trans))
)
(none)
)
:code
(behavior ()
(vector-reset! (-> self collide-info transv))
(set! (-> self jump-length) 32768.0)
(set! (-> self nav-enemy-flags) (logand -9 (-> self nav-enemy-flags)))
(while #t
(cond
((= (if (> (-> self skel active-channels) 0)
(-> self skel root-channel 0 frame-group)
)
(-> self draw art-group data 7)
)
(ja-channel-push! 1 20)
(let ((a0-6 (-> self skel root-channel 0)))
(set!
(-> a0-6 frame-group)
(the-as art-joint-anim (-> self draw art-group data 8))
)
(set!
(-> a0-6 param 0)
(the
float
(+
(->
(the-as art-joint-anim (-> self draw art-group data 8))
data
0
length
)
-1
)
)
)
(set! (-> a0-6 param 1) 1.0)
(set! (-> a0-6 frame-num) 0.0)
(joint-control-channel-group!
a0-6
(the-as art-joint-anim (-> self draw art-group data 8))
num-func-seek!
)
)
(until (ja-done? 0)
(suspend)
(let ((a0-7 (-> self skel root-channel 0)))
(set!
(-> a0-7 param 0)
(the float (+ (-> a0-7 frame-group data 0 length) -1))
)
(set! (-> a0-7 param 1) 1.0)
(joint-control-channel-group-eval!
a0-7
(the-as art-joint-anim #f)
num-func-seek!
)
)
)
(ja-channel-push! 1 30)
)
((= (if (> (-> self skel active-channels) 0)
(-> self skel root-channel 0 frame-group)
)
(-> self draw art-group data 9)
)
(ja-channel-push! 1 30)
(let ((a0-15 (-> self skel root-channel 0)))
(set!
(-> a0-15 frame-group)
(the-as art-joint-anim (-> self draw art-group data 10))
)
(set!
(-> a0-15 param 0)
(the
float
(+
(->
(the-as art-joint-anim (-> self draw art-group data 10))
data
0
length
)
-1
)
)
)
(set! (-> a0-15 param 1) 1.0)
(set! (-> a0-15 frame-num) 0.0)
(joint-control-channel-group!
a0-15
(the-as art-joint-anim (-> self draw art-group data 10))
num-func-seek!
)
)
(until (ja-done? 0)
(suspend)
(let ((a0-16 (-> self skel root-channel 0)))
(set!
(-> a0-16 param 0)
(the float (+ (-> a0-16 frame-group data 0 length) -1))
)
(set! (-> a0-16 param 1) 1.0)
(joint-control-channel-group-eval!
a0-16
(the-as art-joint-anim #f)
num-func-seek!
)
)
)
(ja-channel-push! 1 30)
)
(else
(ja-channel-push! 1 22)
)
)
(set! (-> self state-time) (-> *display* base-frame-counter))
(let ((gp-0 (-> self skel root-channel 0)))
(joint-control-channel-group-eval!
gp-0
(the-as art-joint-anim (-> self draw art-group data 5))
num-func-identity
)
(set! (-> gp-0 frame-num) 0.0)
)
(until (>= (- (-> *display* base-frame-counter) (-> self state-time)) 60)
(suspend)
(let ((a0-21 (-> self skel root-channel 0)))
(set! (-> a0-21 param 0) 1.0)
(joint-control-channel-group-eval!
a0-21
(the-as art-joint-anim #f)
num-func-loop!
)
)
)
(set! (-> self nav target-pos quad) (-> (target-pos 0) quad))
(hopper-do-jump)
)
(none)
)
:post
(the-as (function none :behavior hopper) nav-enemy-jump-post)
)
(defstate nav-enemy-stop-chase (hopper)
:virtual #t
:event
(the-as
(function process int symbol event-message-block object :behavior hopper)
nav-enemy-default-event-handler
)
:code
(behavior ()
(go-virtual nav-enemy-stare)
(none)
)
)
(define
*hopper-nav-enemy-info*
(new 'static 'nav-enemy-info
:idle-anim 5
:walk-anim 5
:turn-anim 9
:notice-anim 5
:run-anim 5
:jump-anim 7
:jump-land-anim 8
:victory-anim 6
:taunt-anim 6
:die-anim 11
:neck-joint -1
:player-look-at-joint 5
:run-travel-speed (meters 10.0)
:run-rotate-speed (degrees 7999.9995)
:run-acceleration (meters 1.0)
:run-turn-time (seconds 0.1)
:walk-travel-speed (meters 6.0)
:walk-rotate-speed (degrees 7999.9995)
:walk-acceleration (meters 1.0)
:walk-turn-time (seconds 0.1)
:attack-shove-back (meters 3.0)
:attack-shove-up (meters 2.0)
:shadow-size (meters 2.0)
:notice-nav-radius (meters 1.0)
:nav-nearest-y-threshold (meters 10.0)
:notice-distance (meters 30.0)
:stop-chase-distance (meters 40.0)
:frustration-distance (meters 8.0)
:frustration-time #x4b0
:die-anim-hold-frame 10000000000.0
:jump-anim-start-frame 3.0
:jump-land-anim-end-frame 10000000000.0
:jump-height-min (meters 3.0)
:jump-height-factor 0.5
:jump-start-anim-speed 1.0
:shadow-max-y (meters 1.0)
:shadow-min-y (meters -1.0)
:shadow-locus-dist (meters 150.0)
:use-align #t
:draw-shadow #t
:move-to-ground #t
:hover-if-no-ground #f
:use-momentum #f
:use-flee #t
:use-proximity-notice #f
:use-jump-blocked #f
:use-jump-patrol #f
:gnd-collide-with #x1
:debug-draw-neck #f
:debug-draw-jump #t
)
)
(defmethod initialize-collision hopper ((obj hopper))
(let
((s5-0
(new
'process
'collide-shape-moving
obj
(collide-list-enum usually-hit-by-player)
)
)
)
(set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> s5-0 reaction) default-collision-reaction)
(set!
(-> s5-0 no-reaction)
(the-as
(function collide-shape-moving collide-shape-intersect vector vector none)
nothing
)
)
(let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 2) 0)))
(set! (-> s4-0 prim-core collide-as) (the-as uint 256))
(set! (-> s4-0 collide-with) (the-as uint 16))
(set! (-> s4-0 prim-core action) (the-as uint 1))
(set-vector! (-> s4-0 local-sphere) 0.0 4096.0 0.0 10240.0)
(set-root-prim! s5-0 s4-0)
(let ((s3-0 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
(set! (-> s3-0 prim-core collide-as) (the-as uint 256))
(set! (-> s3-0 collide-with) (the-as uint 16))
(set! (-> s3-0 prim-core action) (the-as uint 1))
(set! (-> s3-0 prim-core offense) 1)
(set-vector! (-> s3-0 local-sphere) 0.0 4096.0 0.0 4096.0)
(append-prim s4-0 s3-0)
)
(let ((s3-1 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 3))))
(set! (-> s3-1 prim-core collide-as) (the-as uint 256))
(set! (-> s3-1 collide-with) (the-as uint 16))
(set! (-> s3-1 prim-core action) (the-as uint 1))
(set! (-> s3-1 prim-core offense) 1)
(set-vector! (-> s3-1 local-sphere) 0.0 6963.2 0.0 4096.0)
(append-prim s4-0 s3-1)
)
)
(set! (-> s5-0 nav-radius) 6144.0)
(backup-collide-with-as s5-0)
(set! (-> s5-0 max-iteration-count) (the-as uint 2))
(set! (-> obj collide-info) s5-0)
)
0
(none)
)
(defmethod TODO-RENAME-48 hopper ((obj hopper))
(initialize-skeleton obj *hopper-sg* '())
(TODO-RENAME-45 obj *hopper-nav-enemy-info*)
(set!
(-> obj shadow-min-y)
(+ (-> obj collide-info trans y) (-> obj nav-info shadow-min-y))
)
0
(none)
)