Files
jak-project/goal_src/jak2/levels/common/enemy/hopper.gc
T
water111 637990314b wip: better stack var support (#4222)
Closes #736

---------

Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
2026-04-19 00:14:44 +02:00

1020 lines
36 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: hopper.gc
;; name in dgo: hopper
;; dgos: MTN, STA
;; DECOMP BEGINS
(deftype hopper (nav-enemy)
((speed-y float)
(accel-y float)
(next-jump-time int32)
(path-intro path-control)
(can-go-knocked? symbol)
(land-anim-index int32)
(step-num int32)
(best-point vector :inline)
(best-score float)
(origin vector :inline)
(direction vector :inline)
(jump-dist float)
(side float)
(jump-start-anim uint32)
(jump-air-anim uint32)
(jump-land-anim uint32)
(jump-height-min float)
(jump-anim-start-frame float)
(minimap connection-minimap)
)
(:methods
(hopper-method-178 (_type_) symbol)
(hopper-method-179 (_type_) none)
)
)
(defskelgroup skel-hopper hopper hopper-lod0-jg hopper-idle-ja
((hopper-lod0-mg (meters 20)) (hopper-lod1-mg (meters 999999)))
:bounds (static-spherem 0 2.25 -0.7 6.5)
:shadow hopper-shadow-mg
)
(deftype hopper-anim-info (structure)
((hit-anim-index int32)
(land-anim-index int32)
)
:pack-me
)
(deftype hopper-global-info (basic)
((prev-yellow-hit int8)
(prev-blue-hit int8)
(yellow-hit-anim hopper-anim-info 3 :inline)
(blue-hit-anim hopper-anim-info 3 :inline)
)
)
(define *hopper-global-info* (new 'static 'hopper-global-info
:yellow-hit-anim (new 'static 'inline-array hopper-anim-info 3
(new 'static 'hopper-anim-info :hit-anim-index 25 :land-anim-index 26)
(new 'static 'hopper-anim-info :hit-anim-index 27 :land-anim-index 28)
(new 'static 'hopper-anim-info :hit-anim-index 29 :land-anim-index 30)
)
:blue-hit-anim (new 'static 'inline-array hopper-anim-info 3
(new 'static 'hopper-anim-info :hit-anim-index 21 :land-anim-index 24)
(new 'static 'hopper-anim-info :hit-anim-index 22 :land-anim-index 24)
(new 'static 'hopper-anim-info :hit-anim-index 23 :land-anim-index 24)
)
)
)
(defmethod enemy-method-77 ((this hopper) (arg0 enemy-knocked-info))
(case (-> this incoming knocked-type)
(((knocked-type knocked-type-6))
(let* ((a2-0 (ash 1 (-> *hopper-global-info* prev-blue-hit)))
(v1-3 (rnd-bit this 3 a2-0))
(a1-5 (-> this draw art-group data (-> *hopper-global-info* blue-hit-anim v1-3 hit-anim-index)))
)
(set! (-> *hopper-global-info* prev-blue-hit) v1-3)
(let ((a0-12 (-> this skel root-channel 0)))
(set! (-> a0-12 frame-group) (the-as art-joint-anim a1-5))
(set! (-> a0-12 param 0) (the float (+ (-> (the-as art-joint-anim a1-5) frames num-frames) -1)))
(set! (-> a0-12 param 1) 1.0)
(set! (-> a0-12 frame-num) 0.0)
(joint-control-channel-group! a0-12 (the-as art-joint-anim a1-5) num-func-seek!)
)
)
)
(else
(ja-channel-push! 1 (seconds 0.1))
(let* ((a2-2 (ash 1 (-> *hopper-global-info* prev-yellow-hit)))
(v1-13 (rnd-bit this 3 a2-2))
(a1-11 (-> this draw art-group data (-> *hopper-global-info* yellow-hit-anim v1-13 hit-anim-index)))
)
(set! (-> this land-anim-index) (-> *hopper-global-info* yellow-hit-anim v1-13 land-anim-index))
(set! (-> *hopper-global-info* prev-yellow-hit) v1-13)
(let ((a0-27 (-> this skel root-channel 0)))
(set! (-> a0-27 frame-group) (the-as art-joint-anim a1-11))
(set! (-> a0-27 param 0) (the float (+ (-> (the-as art-joint-anim a1-11) frames num-frames) -1)))
(set! (-> a0-27 param 1) (-> arg0 anim-speed))
(set! (-> a0-27 frame-num) 0.0)
(joint-control-channel-group! a0-27 (the-as art-joint-anim a1-11) num-func-seek!)
)
)
)
)
#t
)
(defmethod enemy-method-78 ((this hopper) (arg0 enemy-knocked-info))
(cond
((= (-> this incoming knocked-type) (knocked-type knocked-type-6))
(when (>= (-> this incoming blue-juggle-count) (the-as uint 2))
(let ((s4-0 (-> this draw art-group data 24)))
(ja-channel-push! 1 (seconds 0.1))
(let ((a0-3 (-> this skel root-channel 0)))
(set! (-> a0-3 frame-group) (the-as art-joint-anim s4-0))
(set! (-> a0-3 param 0) (the float (+ (-> (the-as art-joint-anim s4-0) frames num-frames) -1)))
(set! (-> a0-3 param 1) (-> arg0 anim-speed))
(set! (-> a0-3 frame-num) 0.0)
(joint-control-channel-group! a0-3 (the-as art-joint-anim s4-0) num-func-seek!)
)
)
#t
)
#f
)
(else
(ja-channel-push! 1 (seconds 0.1))
(let ((a0-5 (-> this skel root-channel 0)))
(set! (-> a0-5 frame-group) (the-as art-joint-anim (-> this draw art-group data (-> this land-anim-index))))
(set! (-> a0-5 param 0)
(the float
(+ (-> (the-as art-joint-anim (-> this draw art-group data (-> this land-anim-index))) frames num-frames) -1)
)
)
(set! (-> a0-5 param 1) (-> arg0 anim-speed))
(set! (-> a0-5 frame-num) 0.0)
(joint-control-channel-group!
a0-5
(the-as art-joint-anim (-> this draw art-group data (-> this land-anim-index)))
num-func-seek!
)
)
#t
)
)
)
(define *hopper-nav-enemy-info*
(new 'static 'nav-enemy-info
:use-die-falling #t
:use-victory #f
:use-jump-blocked #f
:debug-draw-neck #f
:jump-debug-draw #f
:move-to-ground #t
:hover-if-no-ground #f
:idle-anim-script (new 'static 'array idle-control-frame 8
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x4 :param0 #x1 :param1 #x5)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x5 :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x4 :param0 #x1 :param1 #x5)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x6 :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame)
(new 'static 'idle-control-frame)
(new 'static 'idle-control-frame)
(new 'static 'idle-control-frame)
)
:idle-anim 4
:notice-anim 7
:hostile-anim 4
:hit-anim 4
:knocked-anim 25
:knocked-land-anim 26
:die-anim 19
:die-falling-anim 20
:victory-anim -1
:jump-wind-up-anim -1
:jump-in-air-anim -1
:jump-land-anim -1
:neck-joint 5
:look-at-joint 5
:bullseye-joint 4
:sound-hit (static-sound-name "hopper-hit")
:sound-die (static-sound-name "hopper-die")
:notice-distance (meters 40)
:notice-distance-delta (meters 40)
:proximity-notice-distance (meters 4)
:default-hit-points 1
:gnd-collide-with (collide-spec backgnd)
:overlaps-others-collide-with-filter (collide-spec jak bot player-list)
:penetrate-knocked (penetrate
touch
generic-attack
lunge
flop
punch
spin
roll
uppercut
bonk
tube
vehicle
flut-attack
board
mech
mech-punch
mech-bonk
dark-skin
dark-punch
dark-bomb
dark-giant
shield
explode
jak-yellow-shot
jak-red-shot
jak-blue-shot
jak-dark-shot
enemy-yellow-shot
enemy-dark-shot
eco-yellow
eco-red
eco-blue
eco-green
knocked
penetrate-33
penetrate-34
penetrate-35
penetrate-36
penetrate-37
penetrate-38
penetrate-39
penetrate-40
penetrate-41
penetrate-42
penetrate-43
penetrate-44
penetrate-45
penetrate-46
penetrate-47
penetrate-48
penetrate-49
penetrate-50
penetrate-51
penetrate-52
penetrate-53
penetrate-54
penetrate-55
penetrate-56
penetrate-57
penetrate-58
penetrate-59
penetrate-60
penetrate-61
penetrate-62
penetrate-63
)
:movement-gravity (meters -100)
:friction 0.8
:attack-shove-back (meters 3)
:attack-shove-up (meters 2)
:attack-mode 'generic
:attack-damage 2
:recover-gnd-collide-with (collide-spec backgnd crate obstacle hit-by-others-list pusher)
:jump-height-min (meters 3)
:jump-height-factor 0.5
:knocked-seek-ry-clamp 4551.1113
:knocked-soft-vxz-lo 72089.6
:knocked-soft-vxz-hi 108134.4
:knocked-soft-vy-lo 81920.0
:knocked-soft-vy-hi 122880.0
:knocked-medium-vxz-lo 147456.0
:knocked-medium-vxz-hi 196608.0
:knocked-medium-vy-lo 135168.0
:knocked-medium-vy-hi 151552.0
:knocked-hard-vxz-lo 78643.2
:knocked-hard-vxz-hi 117964.8
:knocked-hard-vy-lo 183500.8
:knocked-hard-vy-hi 209715.2
:knocked-huge-vxz-lo 164659.2
:knocked-huge-vxz-hi 249036.8
:knocked-huge-vy-lo 183500.8
:knocked-huge-vy-hi 217907.2
:knocked-yellow-vxz-lo 40960.0
:knocked-yellow-vxz-hi 49152.0
:knocked-yellow-vy-lo 57344.0
:knocked-yellow-vy-hi 81920.0
:knocked-red-vxz-lo 24576.0
:knocked-red-vxz-hi 196608.0
:knocked-red-vy-lo 94208.0
:knocked-red-vy-hi 151552.0
:knocked-blue-vxz-lo 40960.0
:knocked-blue-vxz-hi 49152.0
:knocked-blue-vy-lo 24576.0
:knocked-blue-vy-hi 81920.0
:shadow-size (meters 2)
:shadow-max-y (meters 1)
:shadow-min-y (meters -1)
:shadow-locus-dist (meters 150)
:gem-joint 5
:gem-seg #x2
:gem-no-seg #x4
:gem-offset (new 'static 'sphere :y 1843.2 :z 1884.16 :r 163840.0)
:callback-info #f
:use-momentum #f
:use-frustration #t
:use-stop-chase #f
:use-circling #f
:use-pacing #f
:walk-anim 4
:turn-anim 9
:run-anim 13
:taunt-anim -1
:run-travel-speed (meters 1)
:run-acceleration (meters 1)
:run-turning-acceleration (meters 2)
:walk-travel-speed (meters 1)
:walk-acceleration (meters 1)
:walk-turning-acceleration (meters 3)
:maximum-rotation-rate (degrees 720)
:notice-nav-radius (meters 2)
:frustration-distance (meters 8)
:frustration-time (seconds 4)
:blocked-time (seconds 0.3)
:circle-dist-lo 20480.0
:circle-dist-hi 61440.0
:nav-mesh #f
)
)
(set! (-> *hopper-nav-enemy-info* fact-defaults) *fact-info-enemy-defaults*)
(defmethod kill-prefer-falling ((this hopper))
"If available in `enemy-info`, [[go]] to the [[die-falling]] state, if not, [[die]]"
(cond
((-> this can-go-knocked?)
(set! (-> this can-go-knocked?) #f)
(go (method-of-object this knocked))
)
(else
((method-of-type nav-enemy kill-prefer-falling) this)
)
)
)
(defmethod enemy-method-90 ((this hopper) (arg0 int) (arg1 enemy-jump-info))
(when (= (-> this jump-why) 2)
(cond
((zero? arg0)
(logior! (-> this focus-status) (focus-status touch-water under-water))
)
(else
(when (focus-test? this touch-water)
(let ((s3-0 (new 'stack-no-clear 'water-info)))
(water-info-init! (-> this root) s3-0 (collide-action solid semi-solid))
(let ((v1-9 #f))
(cond
((not (logtest? (water-flags touch-water) (-> s3-0 flags)))
(if (focus-test? this under-water)
(set! v1-9 #t)
)
(logclear! (-> this focus-status) (focus-status touch-water under-water))
)
((focus-test? this under-water)
(let ((f0-1 (+ 11264.0 (-> this root trans y))))
(if (< (-> s3-0 trans y) f0-1)
(set! v1-9 #t)
)
)
)
)
(when v1-9
(logclear! (-> this focus-status) (focus-status under-water))
(let ((s2-0 (new 'stack-no-clear 'vector)))
(set! (-> s2-0 quad) (-> this root trans quad))
(when (logtest? (water-flags touch-water) (-> s3-0 flags))
(set! (-> s2-0 y) (-> s3-0 trans y))
(part-tracker-spawn :to *entity-pool* :group group-part-water-splash :mat-joint s2-0)
(sound-play "splash-out")
)
)
)
)
)
)
)
)
)
((method-of-type nav-enemy enemy-method-90) this arg0 arg1)
)
(defmethod enemy-method-89 ((this hopper) (arg0 enemy-jump-info))
(ja-channel-push! 1 (seconds 0.1))
(let ((a1-2 (-> this draw art-group data (-> this jump-start-anim)))
(a0-4 (-> this skel root-channel 0))
)
(set! (-> a0-4 frame-group) (the-as art-joint-anim a1-2))
(set! (-> a0-4 param 0) (the float (+ (-> (the-as art-joint-anim a1-2) frames num-frames) -1)))
(set! (-> a0-4 param 1) (-> arg0 anim-speed))
(set! (-> a0-4 frame-num) 0.0)
(joint-control-channel-group! a0-4 (the-as art-joint-anim a1-2) num-func-seek!)
)
#t
)
(defmethod enemy-method-87 ((this hopper) (arg0 enemy-jump-info))
(ja-channel-push! 1 (seconds 0.1))
(let ((a1-2 (-> this draw art-group data (-> this jump-air-anim)))
(a0-4 (-> this skel root-channel 0))
)
(set! (-> a0-4 frame-group) (the-as art-joint-anim a1-2))
(set! (-> a0-4 param 0) (the float (+ (-> (the-as art-joint-anim a1-2) frames num-frames) -1)))
(set! (-> a0-4 param 1) (-> arg0 anim-speed))
(set! (-> a0-4 frame-num) 0.0)
(joint-control-channel-group! a0-4 (the-as art-joint-anim a1-2) num-func-seek!)
)
#t
)
(defmethod enemy-method-88 ((this hopper) (arg0 enemy-jump-info))
(ja-channel-push! 1 (seconds 0.075))
(let ((a1-2 (-> this draw art-group data (-> this jump-land-anim)))
(a0-4 (-> this skel root-channel 0))
)
(set! (-> a0-4 frame-group) (the-as art-joint-anim a1-2))
(set! (-> a0-4 param 0) (the float (+ (-> (the-as art-joint-anim a1-2) frames num-frames) -1)))
(set! (-> a0-4 param 1) (-> arg0 anim-speed))
(set! (-> a0-4 frame-num) 0.0)
(joint-control-channel-group! a0-4 (the-as art-joint-anim a1-2) num-func-seek!)
)
#t
)
(defstate jump (hopper)
:virtual #t
:enter (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy jump) enter)))
(if t9-0
(t9-0)
)
)
)
:exit (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy jump) exit)))
(if t9-0
(t9-0)
)
)
(let ((v1-5 (-> self draw shadow-ctrl)))
(logclear! (-> v1-5 settings flags) (shadow-flags shdf03))
(let ((a0-2 v1-5))
(set! (-> a0-2 settings top-plane w) (- 4096.0))
)
0
(set! (-> v1-5 settings bot-plane w) (- -4096.0))
)
0
)
:trans (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy jump) trans)))
(if t9-0
(t9-0)
)
)
(let ((v1-5 (-> self draw shadow-ctrl)))
(logior! (-> v1-5 settings flags) (shadow-flags shdf03))
(let ((a0-2 v1-5))
(set! (-> a0-2 settings bot-plane w) (- (+ (- -4096.0 (-> self root trans y)) (-> self root gspot-pos y))))
)
0
(set! (-> v1-5 settings top-plane w) (- (+ (- 8192.0 (-> self root trans y)) (-> self root gspot-pos y))))
)
0
)
)
(defmethod hopper-method-178 ((this hopper))
(rlet ((acc :class vf)
(vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
(vf7 :class vf)
)
(init-vf0-vector)
(+! (-> this step-num) -1)
(cond
((>= (-> this step-num) 0)
(let ((s3-0 (new 'stack-no-clear 'vector))
(s5-0 (new 'stack-no-clear 'vector))
)
(vector-rotate-around-y!
s3-0
(-> this direction)
(* 182.04445 (the float (+ (* (-> this step-num) 16) -135)))
)
(let ((a1-1 s5-0))
(let ((v1-7 (-> this origin)))
(let ((a0-2 s3-0))
(let ((a2-1 (-> this jump-dist)))
(.mov vf7 a2-1)
)
(.lvf vf5 (&-> a0-2 quad))
)
(.lvf vf4 (&-> v1-7 quad))
)
(.add.x.vf.w vf6 vf0 vf0)
(.mul.x.vf.xyz acc vf5 vf7)
(.add.mul.w.vf.xyz vf6 vf4 vf0 acc)
(.svf (&-> a1-1 quad) vf6)
)
(let ((v1-8 (-> this nav))
(a0-3 s5-0)
(a1-2 (new 'stack-no-clear 'nav-find-poly-parms))
)
(vector-! (-> a1-2 point) a0-3 (-> v1-8 state mesh bounds))
(set! (-> a1-2 y-threshold) (-> v1-8 nearest-y-threshold))
(set! (-> a1-2 ignore) (the-as uint 2))
(let ((s4-0 (find-poly-containing-point-local (-> v1-8 state mesh) a1-2)))
(when s4-0
(let ((f30-0 (vector-dot s3-0 (-> this direction))))
(new 'stack-no-clear 'vector)
(let ((a1-3 (new 'stack-no-clear 'vector)))
(set! (-> a1-3 quad) (-> s5-0 quad))
(set! (-> a1-3 w) 6144.0)
(when (not (add-root-sphere-to-hash! (-> this nav) a1-3 #x8006c))
(when (< (-> this best-score) f30-0)
(set! (-> this best-score) f30-0)
(let ((s2-0 (new 'stack-no-clear 'vector))
(sv-752 (new 'stack-no-clear 'vector))
(s3-1 (new 'stack 'collide-query))
)
(let ((s0-0 (-> this nav))
(s1-0 s2-0)
)
(let ((v1-21 s5-0))
(project-point-onto-plane-of-poly-local
(-> s0-0 state mesh)
s4-0
s1-0
sv-752
(vector-! (new 'stack-no-clear 'vector) v1-21 (-> s0-0 state mesh bounds))
)
)
(vector+! s1-0 s1-0 (-> s0-0 state mesh bounds))
)
0
(set! (-> s5-0 y) (-> s2-0 y))
(if (enemy-above-ground? this s3-1 s5-0 (collide-spec backgnd) 8192.0 81920.0 1024.0)
(set! (-> s5-0 y) (-> s3-1 best-other-tri intersect y))
)
)
(set! (-> this best-point quad) (-> s5-0 quad))
)
)
)
)
)
)
)
)
#t
)
(else
#f
)
)
)
)
(defstate stare (hopper)
:virtual #t
:enter (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy stare) enter)))
(if t9-0
(t9-0)
)
)
(let ((v1-4 self))
(set! (-> v1-4 enemy-flags) (the-as enemy-flag (logclear (-> v1-4 enemy-flags) (enemy-flag enemy-flag37))))
)
0
)
)
(define *hopper-next-jump-time* (the-as time-frame 0))
(defstate hostile (hopper)
:virtual #t
:enter (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy hostile) enter)))
(if t9-0
(t9-0)
)
)
(let ((v1-4 self))
(set! (-> v1-4 enemy-flags) (the-as enemy-flag (logclear (-> v1-4 enemy-flags) (enemy-flag enemy-flag36))))
(set! (-> v1-4 nav callback-info) *nav-enemy-null-callback-info*)
)
0
(let ((v1-7 self))
(set! (-> v1-7 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag37) (-> v1-7 enemy-flags))))
)
0
(set! (-> self speed-y) 0.0)
(set! (-> self accel-y) 0.0)
(set! (-> self next-jump-time) (the-as int (+ (current-time) (rnd-int-range self 0 120))))
(set! (-> self step-num) 0)
(set! (-> self best-score) -2.0)
)
:exit (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy hostile) exit)))
(if t9-0
(t9-0)
)
)
)
:trans (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy hostile) trans)))
(if t9-0
(t9-0)
)
)
(when (< *hopper-next-jump-time* (current-time))
(let ((gp-0 (handle->process (-> self focus handle))))
(when gp-0
(let ((s4-1
(vector-! (new 'stack-no-clear 'vector) (get-trans (the-as process-focusable gp-0) 0) (-> self root trans))
)
)
0.0
(let ((s5-0 (rnd-int-count self 2)))
(set! (-> self direction y) 0.0)
(let* ((v1-12 s4-1)
(f30-0 (sqrtf (+ (* (-> v1-12 x) (-> v1-12 x)) (* (-> v1-12 z) (-> v1-12 z)))))
)
(set! (-> self step-num) 16)
(set! (-> self direction quad) (-> s4-1 quad))
0.0
(let ((s4-2 (new 'stack-no-clear 'vector))
(f28-0 (if (zero? s5-0)
(rnd-float-range self 4096.0 8192.0)
(rnd-float-range self 8192.0 (fmin 40960.0 (fmax 16384.0 (/ f30-0 2))))
)
)
)
(vector-rotate90-around-y! s4-2 (-> self direction))
(vector-normalize! (-> self direction) 1.0)
(if (< (+ -2048.0 f30-0) f28-0)
(set! f28-0 (+ -2048.0 f30-0))
)
(if (< f28-0 6144.0)
(set! s5-0 0)
)
(set! (-> self jump-dist) f28-0)
)
)
(set! (-> self best-score) -2.0)
(set! (-> self origin quad) (-> self root trans quad))
;; og:preserve-this
; (b! #t cfg-17)
(until (not (hopper-method-178 self))
(empty)
)
(when (!= (-> self best-score) -2.0)
(let* ((s4-4 (vector-! (new 'stack-no-clear 'vector) (-> self best-point) (-> self root trans)))
(f30-1 (deg-diff (quaternion-y-angle (-> self root quat)) (vector-y-angle s4-4)))
)
(cond
((< (vector-vector-xz-distance (-> self best-point) (get-trans (the-as process-focusable gp-0) 0)) 8192.0)
(when (get-enemy-target self)
(cond
((zero? s5-0)
(set! (-> self jump-start-anim) (the-as uint 34))
(set! (-> self jump-air-anim) (the-as uint 35))
(set! (-> self jump-land-anim) (the-as uint 36))
(set! (-> self jump-height-min) 4096.0)
(set! (-> self jump-anim-start-frame) 2.0)
)
(else
(if (< 2730.6667 (fabs f30-1))
(set! (-> self jump-start-anim) (the-as uint (if (< 0.0 f30-1)
11
12
)
)
)
(set! (-> self jump-start-anim) (the-as uint 10))
)
(cond
((zero? (rnd-int-count self 2))
(set! (-> self jump-air-anim) (the-as uint 15))
(set! (-> self jump-land-anim) (the-as uint 16))
(set! (-> self jump-height-min) 12288.0)
(set! (-> self jump-anim-start-frame) 8.0)
)
(else
(set! (-> self jump-air-anim) (the-as uint 17))
(set! (-> self jump-land-anim) (the-as uint 18))
(set! (-> self jump-height-min) 12288.0)
(set! (-> self jump-anim-start-frame) 8.0)
)
)
)
)
(set! *hopper-next-jump-time* (+ (current-time) (rnd-int-range self 4 22)))
(set! (-> self enemy-flags)
(the-as enemy-flag (logclear (-> self enemy-flags) (enemy-flag jump-check-blocked)))
)
(send-event self 'jump 0 (-> self best-point))
)
)
(else
(cond
((zero? s5-0)
(set! (-> self jump-start-anim) (the-as uint 31))
(set! (-> self jump-air-anim) (the-as uint 32))
(set! (-> self jump-land-anim) (the-as uint 33))
(set! (-> self jump-height-min) 4096.0)
(set! (-> self jump-anim-start-frame) 2.0)
)
(else
(if (< 2730.6667 (fabs f30-1))
(set! (-> self jump-start-anim) (the-as uint (if (< 0.0 f30-1)
11
12
)
)
)
(set! (-> self jump-start-anim) (the-as uint 10))
)
(set! (-> self jump-air-anim) (the-as uint 13))
(set! (-> self jump-land-anim) (the-as uint 14))
(set! (-> self jump-height-min) 12288.0)
(set! (-> self jump-anim-start-frame) 8.0)
)
)
(set! *hopper-next-jump-time* (+ (current-time) (rnd-int-range self 4 22)))
(set! (-> self enemy-flags)
(the-as enemy-flag (logclear (-> self enemy-flags) (enemy-flag jump-check-blocked)))
)
(send-event self 'jump 0 (-> self best-point))
)
)
)
)
)
)
)
)
)
)
:post nav-enemy-simple-post
)
(defstate active (hopper)
:virtual #t
:enter (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy active) enter)))
(if t9-0
(t9-0)
)
)
)
:code (behavior ()
(ja-channel-push! 1 (seconds 0.2))
(let ((f30-0 (rnd-float-range self 0.9 1.1)))
(until #f
(ja-no-eval :group! hopper-idle-ja :num! (seek! max f30-0) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
)
)
#f
)
:post nav-enemy-simple-post
)
(defstate notice (hopper)
:virtual #t
:code (behavior ()
(ja-channel-push! 1 (seconds 0.075))
(let ((f30-0 (rnd-float-range self 0.8 1.2))
(gp-0 (new 'stack-no-clear 'vector))
)
(if (zero? (rnd-int-count self 2))
(ja :group! hopper-notice-ja)
(ja :group! hopper-notice-alt-ja)
)
(ja-no-eval :group! (ja-group) :num! (seek! max f30-0) :frame-num 0.0)
(until (ja-done? 0)
(let ((a1-4 (-> self nav state)))
(set! (-> gp-0 quad) (-> a1-4 travel quad))
)
(seek-toward-heading-vec! (-> self root) gp-0 (-> self nav max-rotation-rate) (seconds 0.02))
(suspend)
(ja :num! (seek! max f30-0))
)
)
(react-to-focus self)
)
)
(defstate ambush (hopper)
:virtual #t
:enter (behavior ()
(when (logtest? (-> self enemy-flags) (enemy-flag enable-on-notice))
(logclear! (-> self enemy-flags) (enemy-flag enable-on-notice))
(let ((gp-0 (-> self on-notice)))
(if gp-0
(script-eval gp-0 :vector (-> self root trans))
)
)
)
(let ((v1-12 (-> self root root-prim)))
(set! (-> self root backup-collide-as) (-> v1-12 prim-core collide-as))
(set! (-> self root backup-collide-with) (-> v1-12 prim-core collide-with))
)
(let ((v1-15 (-> self root root-prim)))
(set! (-> v1-15 prim-core collide-as) (collide-spec))
(set! (-> v1-15 prim-core collide-with) (collide-spec))
)
0
(when (handle->process (-> self focus handle))
(let ((gp-1 (-> self root))
(s5-0 (new 'stack-no-clear 'vector))
)
(let ((s4-0 (new 'stack-no-clear 'vector)))
0.0
(get-point-in-path! (-> self path-intro) s5-0 0.0 'exact)
(+! (-> s5-0 y) -16384.0)
(get-point-in-path! (-> self path-intro) s4-0 1.0 'exact)
(let ((f0-3 (deg-diff
(quaternion-y-angle (-> gp-1 quat))
(vector-y-angle (vector-normalize! (vector-! (new 'stack-no-clear 'vector) s4-0 s5-0) 1.0))
)
)
)
(quaternion-rotate-y! (-> gp-1 quat) (-> gp-1 quat) f0-3)
)
)
(set! (-> gp-1 trans quad) (-> s5-0 quad))
)
)
)
:exit (behavior ()
(let ((v1-1 (-> self root root-prim)))
(set! (-> v1-1 prim-core collide-as) (-> self root backup-collide-as))
(set! (-> v1-1 prim-core collide-with) (-> self root backup-collide-with))
)
)
:trans (behavior ()
'()
)
:code (behavior ()
(logclear! (-> self draw status) (draw-control-status no-draw))
(let ((gp-0 (new 'stack-no-clear 'vector)))
(let ((s5-0 (new 'stack 'collide-query)))
(get-point-in-path! (-> self path-intro) gp-0 1.0 'exact)
(if (enemy-above-ground? self s5-0 gp-0 (collide-spec backgnd) 8192.0 81920.0 1024.0)
(set! (-> gp-0 y) (-> s5-0 best-other-tri intersect y))
)
)
(set! (-> self enemy-flags)
(the-as enemy-flag (logclear (-> self enemy-flags) (enemy-flag jump-check-blocked)))
)
(send-event self 'jump 2 gp-0)
)
(go-virtual hostile)
)
)
(defmethod dying ((this hopper))
"Cleans-up the enemy and any associated resources. Potentially spawns skull gems"
(when (-> this minimap)
(logior! (-> this minimap flags) (minimap-flag fade-out))
(set! (-> this minimap) #f)
)
(call-parent-method this)
(none)
)
(defmethod relocate ((this hopper) (offset int))
(if (nonzero? (-> this path-intro))
(&+! (-> this path-intro) offset)
)
(call-parent-method this offset)
)
(defmethod init-enemy-collision! ((this hopper))
"Initializes the [[collide-shape-moving]] and any ancillary tasks to make the enemy collide properly"
(let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum usually-hit-by-player))))
(set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> s5-0 reaction) cshape-reaction-default)
(set! (-> s5-0 no-reaction)
(the-as (function collide-shape-moving collide-query vector vector object) nothing)
)
(set! (-> s5-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 ((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 enemy))
(set! (-> s4-0 prim-core collide-with)
(collide-spec backgnd jak bot crate obstacle hit-by-others-list player-list)
)
(set! (-> s4-0 prim-core action) (collide-action solid deadly no-standon))
(set! (-> s4-0 transform-index) 12)
(set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 9216.0)
(set! (-> s5-0 root-prim) s4-0)
)
(let ((v1-14 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
(set! (-> v1-14 prim-core collide-as) (collide-spec enemy))
(set! (-> v1-14 prim-core collide-with)
(collide-spec backgnd jak bot crate obstacle hit-by-others-list player-list)
)
(set! (-> v1-14 prim-core action) (collide-action solid no-standon))
(set-vector! (-> v1-14 local-sphere) 0.0 3686.4 0.0 3686.4)
)
(let ((v1-16 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
(set! (-> v1-16 prim-core collide-as) (collide-spec enemy))
(set! (-> v1-16 prim-core collide-with) (collide-spec jak bot player-list))
(set! (-> v1-16 prim-core action) (collide-action deadly))
(set! (-> v1-16 transform-index) 5)
(set-vector! (-> v1-16 local-sphere) 0.0 0.0 819.2 3276.8)
)
(set! (-> s5-0 nav-radius) 4096.0)
(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 3))
(set! (-> this root) s5-0)
)
0
(none)
)
(defmethod init-enemy! ((this hopper))
"Common method called to initialize the enemy, typically sets up default field values and calls ancillary helper methods"
(stack-size-set! (-> this main-thread) 256)
(initialize-skeleton
this
(the-as skeleton-group (art-group-get-by-name *level* "skel-hopper" (the-as (pointer uint32) #f)))
(the-as pair 0)
)
(set! (-> this skel generate-frame-function) create-interpolated2-joint-animation-frame)
(init-enemy-behaviour-and-stats! this *hopper-nav-enemy-info*)
(set! (-> this can-go-knocked?) #t)
(let ((v1-9 (-> this neck)))
(set! (-> v1-9 up) (the-as uint 1))
(set! (-> v1-9 nose) (the-as uint 2))
(set! (-> v1-9 ear) (the-as uint 0))
(set-vector! (-> v1-9 twist-max) 10922.667 12743.111 0.0 1.0)
(set! (-> v1-9 ignore-angle) 18204.445)
)
(set! (-> this jump-start-anim) (the-as uint 10))
(set! (-> this jump-air-anim) (the-as uint 13))
(set! (-> this jump-land-anim) (the-as uint 14))
(set! (-> this jump-height-min) 12288.0)
(set! (-> this jump-anim-start-frame) 8.0)
(set! (-> this land-anim-index) 26)
(set! (-> this side) (rnd-float-range this -1.5 1.5))
(when (logtest? (enemy-option ambush) (-> this fact enemy-options))
(set! (-> this path-intro) (new 'process 'path-control this 'intro 0.0 (-> this entity) #f))
(if (-> this path-intro)
(logior! (-> this path-intro flags) (path-control-flag display draw-line draw-point draw-text))
)
)
(add-connection
*part-engine*
this
5
this
318
(new 'static 'vector :x 1392.64 :y 491.52 :z 1638.4 :w 163840.0)
)
(add-connection
*part-engine*
this
5
this
318
(new 'static 'vector :x -1392.64 :y 491.52 :z 1638.4 :w 163840.0)
)
(logior! (-> this nav flags) (nav-control-flag output-sphere-hash))
(let ((v1-34 (-> this nav)))
(set! (-> v1-34 speed-scale) 1.0)
)
0
(set-gravity-length (-> this root dynam) 327680.0)
(let ((v1-39 (-> this nav)))
(set! (-> v1-39 nav-cull-radius) 61440.0)
)
0
(set! (-> this minimap) (add-icon! *minimap* this (the-as uint 70) (the-as int #f) (the-as vector #t) 0))
0
(none)
)