Files
jak-project/goal_src/jak2/levels/forest/predator.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

1715 lines
60 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: predator.gc
;; name in dgo: predator
;; dgos: FOR
;; DECOMP BEGINS
(defmethod draw ((this hud-predator))
(set-hud-piece-position! (-> this sprites 1) (the int (+ 480.0 (* 130.0 (-> this offset)))) 205)
(set-as-offset-from! (-> this sprites 0) (-> this sprites 1 pos) -44 0)
(format (clear (-> this strings 0 text)) "~D" (-> this values 0 current))
(set-as-offset-from! (the-as hud-sprite (-> this strings 0 pos)) (-> this sprites 1 pos) -45 45)
((method-of-type hud draw) this)
0
(none)
)
(defmethod update-values ((this hud-predator))
(set! (-> this values 0 target) (the int (-> *game-info* counter)))
((method-of-type hud update-values) this)
0
(none)
)
(defmethod init-callback ((this hud-predator))
(set! (-> this level) (level-get *level* 'forest))
(set! (-> this gui-id)
(add-process *gui-control* this (gui-channel hud-middle-right) (gui-action hidden) (-> this name) 81920.0 0)
)
(logior! (-> this flags) (hud-flags show))
(set! (-> this sprites 0 tex) (lookup-texture-by-id (new 'static 'texture-id :index #x2 :page #xb1d)))
(set! (-> this sprites 0 flags) (the-as uint 4))
(set! (-> this sprites 0 scale-x) 0.6)
(set! (-> this sprites 0 scale-y) 0.6)
(set! (-> this sprites 1 tex) (lookup-texture-by-id (new 'static 'texture-id :page #xb1d)))
(set! (-> this sprites 1 flags) (the-as uint 4))
(set! (-> this sprites 1 scale-x) 0.6)
(set! (-> this sprites 1 scale-y) 0.6)
(alloc-string-if-needed this 0)
(set! (-> this strings 0 scale) 0.6)
(set! (-> this strings 0 flags) (font-flags kerning middle large))
0
(none)
)
(defmethod draw ((this hud-pegasus))
(set-hud-piece-position! (-> this sprites 0) (the int (+ 472.0 (* 130.0 (-> this offset)))) 190)
(set! (-> this sprites 0 flags) (the-as uint 4))
(format (clear (-> this strings 0 text)) "~D" (-> this values 0 current))
(set-as-offset-from! (the-as hud-sprite (-> this strings 0 pos)) (-> this sprites 0 pos) -26 35)
((method-of-type hud draw) this)
0
(none)
)
(defmethod update-values ((this hud-pegasus))
(set! (-> this values 0 target) (the int (-> *game-info* counter)))
((method-of-type hud update-values) this)
0
(none)
)
(defmethod init-callback ((this hud-pegasus))
(set! (-> this level) (level-get *level* 'forest))
(set! (-> this gui-id)
(add-process *gui-control* this (gui-channel hud-middle-right) (gui-action hidden) (-> this name) 81920.0 0)
)
(logior! (-> this flags) (hud-flags show))
(set! (-> this sprites 0 tex) (lookup-texture-by-id (new 'static 'texture-id :index #x1 :page #xb1d)))
(set! (-> this sprites 0 scale-x) 0.8)
(set! (-> this sprites 0 scale-y) 0.8)
(set! (-> this sprites 0 flags) (the-as uint 4))
(alloc-string-if-needed this 0)
(set! (-> this strings 0 scale) 0.6)
(set! (-> this strings 0 flags) (font-flags kerning middle large))
0
(none)
)
(defun point-in-line-region? ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float))
(let* ((v1-1 (vector-normalize! (vector-! (new-stack-vector0) arg2 arg1) 1.0))
(s5-1 (vector-! (new-stack-vector0) arg0 arg1))
(f30-0 (vector-dot v1-1 s5-1))
(s2-2 (vector-float*! (new-stack-vector0) v1-1 f30-0))
)
(if (or (< f30-0 0.0)
(< (vector-vector-distance arg1 arg2) f30-0)
(< arg3 (vector-length (vector-! (new-stack-vector0) s5-1 s2-2)))
)
(return #f)
)
)
#t
)
(deftype predator-shot (metalhead-shot)
()
)
;; WARN: Return type mismatch sound-id vs none.
(defmethod play-impact-sound ((this predator-shot) (arg0 projectile-options))
(case arg0
(((projectile-options lose-altitude))
(sound-play "pred-shot-hit")
)
(((projectile-options lose-altitude proj-options-2))
(let ((f0-0 (doppler-pitch-shift (-> this root trans) (-> this root transv)))
(a0-7 (static-sound-spec "pred-shot-loop" :volume 0.0 :mask (pitch reg0)))
)
(set! (-> a0-7 volume) 1024)
(set! (-> a0-7 pitch-mod) (the int (* 1524.0 f0-0)))
(sound-play-by-spec a0-7 (-> this sound-id) (-> this root trans))
)
)
)
(none)
)
(defmethod init-proj-collision! ((this predator-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)
(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 jak-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 2457.6)
(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! (-> this root) s5-0)
)
(set! (-> this root pat-ignore-mask)
(new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noproj #x1 :noendlessfall #x1)
)
(none)
)
(defmethod init-proj-settings! ((this predator-shot))
"Init relevant settings for the [[projectile]] such as gravity, speed, timeout, etc"
(set! (-> this tail-pos quad) (-> this root trans quad))
(set! (-> this attack-mode) 'predator-shot)
(set! (-> this max-speed) 532480.0)
(set! (-> this move) metalhead-shot-move)
(set! (-> this update-velocity) projectile-update-velocity-space-wars)
(set! (-> this timeout) (seconds 0.767))
(set! (-> this sound-id) (new-sound-id))
(set-gravity-length (-> this root dynam) 573440.0)
(none)
)
(defskelgroup skel-predator predator predator-lod0-jg predator-idle-ja
((predator-lod0-mg (meters 20)) (predator-lod1-mg (meters 40)) (predator-lod2-mg (meters 999999)))
:bounds (static-spherem 0 1 0 4)
)
(deftype predator (nav-enemy)
((los los-control :inline)
(want-stop symbol)
(target-pos vector :inline)
(curr-node int32)
(hide-pos vector :inline)
(next-change uint64)
(shoot-angle float)
(miss-amount float)
(ambient-sound-id sound-id)
(shock-effect-time time-frame)
(shock-effect-end uint64)
(fade float)
(dest-fade float)
)
(:state-methods
close-attack
fire
hide
hidden
)
(:methods
(set-dangerous! (_type_ symbol) symbol)
(predator-method-183 (_type_) none)
(predator-method-184 (_type_ int float) none)
(predator-method-185 (_type_) none)
(predator-method-186 (_type_) none)
(predator-method-187 (_type_) symbol)
(predator-method-188 (_type_ vector vector vector) none)
)
)
(define *predator-nav-enemy-info*
(new 'static 'nav-enemy-info
:use-die-falling #f
: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 4
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x5 :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame)
(new 'static 'idle-control-frame)
(new 'static 'idle-control-frame)
)
:idle-anim 5
:notice-anim 5
:hostile-anim 7
:hit-anim 5
:knocked-anim 12
:knocked-land-anim 13
:die-anim 11
:die-falling-anim 11
:victory-anim 5
:jump-wind-up-anim -1
:jump-in-air-anim -1
:jump-land-anim -1
:neck-joint 7
:look-at-joint 8
:bullseye-joint 6
:sound-hit (static-sound-name "predator-hit")
:sound-die (static-sound-name "predator-die")
:notice-distance (meters 150)
:notice-distance-delta (meters 150)
:proximity-notice-distance (meters 4)
:default-hit-points 5
: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 2730.6667
:knocked-soft-vxz-lo 81920.0
:knocked-soft-vxz-hi 81920.0
:knocked-soft-vy-lo 69632.0
:knocked-soft-vy-hi 69632.0
:knocked-medium-vxz-lo 81920.0
:knocked-medium-vxz-hi 81920.0
:knocked-medium-vy-lo 69632.0
:knocked-medium-vy-hi 69632.0
:knocked-hard-vxz-lo 81920.0
:knocked-hard-vxz-hi 81920.0
:knocked-hard-vy-lo 69632.0
:knocked-hard-vy-hi 69632.0
: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 53248.0
:knocked-yellow-vy-lo 40960.0
:knocked-yellow-vy-hi 53248.0
:knocked-red-vxz-lo 102400.0
:knocked-red-vxz-hi 102400.0
:knocked-red-vy-lo 81920.0
:knocked-red-vy-hi 81920.0
:knocked-blue-vxz-lo 32768.0
:knocked-blue-vxz-hi 65536.0
:knocked-blue-vy-lo 32768.0
:knocked-blue-vy-hi 49152.0
:shadow-size (meters 1)
:shadow-max-y (meters 1)
:shadow-min-y (meters -1)
:shadow-locus-dist (meters 150)
:gem-joint 6
:gem-offset (new 'static 'sphere :y -2252.8 :z -2170.88 :r 163840.0)
:callback-info #f
:use-momentum #t
:use-frustration #t
:use-stop-chase #f
:use-circling #f
:use-pacing #f
:walk-anim 6
:turn-anim -1
:run-anim 7
:taunt-anim -1
:run-travel-speed (meters 8)
:run-acceleration (meters 6)
:run-turning-acceleration (meters 30)
:walk-travel-speed (meters 4)
:walk-acceleration (meters 3)
:walk-turning-acceleration (meters 8)
:maximum-rotation-rate (degrees 720)
:notice-nav-radius (meters 40)
: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! (-> *predator-nav-enemy-info* fact-defaults) *fact-info-enemy-defaults*)
(defmethod general-event-handler ((this predator) (arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
"Handles various events for the enemy
@TODO - unsure if there is a pattern for the events and this should have a more specific name"
(case arg2
(('attack)
(set! (-> this shock-effect-end) (the-as uint (+ (current-time) (seconds 1))))
((method-of-type nav-enemy general-event-handler) this arg0 arg1 arg2 arg3)
)
(('death-end)
(when (nonzero? (-> this ambient-sound-id))
(sound-stop (-> this ambient-sound-id))
(set! (-> this ambient-sound-id) (new 'static 'sound-id))
0
)
((method-of-type nav-enemy general-event-handler) this arg0 arg1 arg2 arg3)
)
(else
((method-of-type nav-enemy general-event-handler) this arg0 arg1 arg2 arg3)
)
)
)
(defmethod enemy-method-77 ((this predator) (arg0 enemy-knocked-info))
(cond
((zero? (-> this hit-points))
(case (-> this incoming knocked-type)
(((knocked-type knocked-type-5))
(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 (-> this draw art-group data 18)))
(set! (-> a0-3 param 0)
(the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 18)) 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 (-> this draw art-group data 18)) num-func-seek!)
)
)
(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 14)))
(set! (-> a0-5 param 0)
(the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 14)) 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 14)) num-func-seek!)
)
)
)
#t
)
(else
(case (-> this incoming knocked-type)
(((knocked-type knocked-type-6))
(ja-channel-push! 1 (seconds 0.01))
(let ((v1-32 (rnd-int-count this 2)))
(cond
((zero? v1-32)
(let ((a0-10 (-> this skel root-channel 0)))
(set! (-> a0-10 frame-group) (the-as art-joint-anim (-> this draw art-group data 21)))
(set! (-> a0-10 param 0)
(the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 21)) frames num-frames) -1))
)
(set! (-> a0-10 param 1) (-> arg0 anim-speed))
(set! (-> a0-10 frame-num) 0.0)
(joint-control-channel-group! a0-10 (the-as art-joint-anim (-> this draw art-group data 21)) num-func-seek!)
)
)
((= v1-32 1)
(let ((a0-12 (-> this skel root-channel 0)))
(set! (-> a0-12 frame-group) (the-as art-joint-anim (-> this draw art-group data 22)))
(set! (-> a0-12 param 0)
(the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 22)) frames num-frames) -1))
)
(set! (-> a0-12 param 1) (-> arg0 anim-speed))
(set! (-> a0-12 frame-num) 0.0)
(joint-control-channel-group! a0-12 (the-as art-joint-anim (-> this draw art-group data 22)) num-func-seek!)
)
)
)
)
)
(((knocked-type knocked-type-5))
(ja-channel-push! 1 (seconds 0.1))
(let ((a0-15 (-> this skel root-channel 0)))
(set! (-> a0-15 frame-group) (the-as art-joint-anim (-> this draw art-group data 18)))
(set! (-> a0-15 param 0)
(the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 18)) frames num-frames) -1))
)
(set! (-> a0-15 param 1) (-> arg0 anim-speed))
(set! (-> a0-15 frame-num) 0.0)
(joint-control-channel-group! a0-15 (the-as art-joint-anim (-> this draw art-group data 18)) num-func-seek!)
)
)
(else
(ja-channel-push! 1 (seconds 0.1))
(let ((a0-17 (-> this skel root-channel 0)))
(set! (-> a0-17 frame-group) (the-as art-joint-anim (-> this draw art-group data 12)))
(set! (-> a0-17 param 0)
(the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 12)) frames num-frames) -1))
)
(set! (-> a0-17 param 1) (-> arg0 anim-speed))
(set! (-> a0-17 frame-num) 0.0)
(joint-control-channel-group! a0-17 (the-as art-joint-anim (-> this draw art-group data 12)) num-func-seek!)
)
)
)
#t
)
)
)
(defmethod enemy-method-78 ((this predator) (arg0 enemy-knocked-info))
(cond
((zero? (-> this hit-points))
(case (-> this incoming knocked-type)
(((knocked-type knocked-type-5))
(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 (-> this draw art-group data 20)))
(set! (-> a0-3 param 0)
(the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 20)) 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 (-> this draw art-group data 20)) num-func-seek!)
)
)
(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 15)))
(set! (-> a0-5 param 0)
(the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 15)) 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 15)) num-func-seek!)
)
)
)
#t
)
(else
(case (-> this incoming knocked-type)
(((knocked-type knocked-type-6))
(ja-channel-push! 1 (seconds 0.01))
(let ((a0-8 (-> this skel root-channel 0)))
(set! (-> a0-8 frame-group) (the-as art-joint-anim (-> this draw art-group data 23)))
(set! (-> a0-8 param 0)
(the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 23)) frames num-frames) -1))
)
(set! (-> a0-8 param 1) (-> arg0 anim-speed))
(set! (-> a0-8 frame-num) 0.0)
(joint-control-channel-group! a0-8 (the-as art-joint-anim (-> this draw art-group data 23)) num-func-seek!)
)
)
(((knocked-type knocked-type-5))
(ja-channel-push! 1 (seconds 0.1))
(let ((a0-11 (-> this skel root-channel 0)))
(set! (-> a0-11 frame-group) (the-as art-joint-anim (-> this draw art-group data 19)))
(set! (-> a0-11 param 0)
(the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 19)) frames num-frames) -1))
)
(set! (-> a0-11 param 1) (-> arg0 anim-speed))
(set! (-> a0-11 frame-num) 0.0)
(joint-control-channel-group! a0-11 (the-as art-joint-anim (-> this draw art-group data 19)) num-func-seek!)
)
)
(else
(ja-channel-push! 1 (seconds 0.1))
(let ((a0-13 (-> this skel root-channel 0)))
(set! (-> a0-13 frame-group) (the-as art-joint-anim (-> this draw art-group data 13)))
(set! (-> a0-13 param 0)
(the float (+ (-> (the-as art-joint-anim (-> this draw art-group data 13)) frames num-frames) -1))
)
(set! (-> a0-13 param 1) (-> arg0 anim-speed))
(set! (-> a0-13 frame-num) 0.0)
(joint-control-channel-group! a0-13 (the-as art-joint-anim (-> this draw art-group data 13)) num-func-seek!)
)
)
)
#t
)
)
)
;; WARN: Return type mismatch symbol vs none.
(defmethod predator-method-188 ((this predator) (arg0 vector) (arg1 vector) (arg2 vector))
(let ((s5-0 (new 'stack-no-clear 'collide-query)))
(let ((f0-0 1228.8)
(f30-0 6144.0)
)
(set! (-> s5-0 start-pos quad) (-> arg0 quad))
(vector-! (-> s5-0 move-dist) arg1 arg0)
(let ((v1-4 s5-0))
(set! (-> v1-4 radius) f0-0)
(set! (-> v1-4 collide-with) (collide-spec backgnd))
(set! (-> v1-4 ignore-process0) this)
(set! (-> v1-4 ignore-process1) (handle->process (-> this focus handle)))
(set! (-> v1-4 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1))
(set! (-> v1-4 action-mask) (collide-action solid))
)
(let ((f0-1 (fill-and-probe-using-line-sphere *collide-cache* s5-0)))
(cond
((>= f0-1 0.0)
(vector-float*! (-> s5-0 move-dist) (-> s5-0 move-dist) f0-1)
(cond
((< (vector-dot
(-> s5-0 best-other-tri normal)
(vector-! (new 'stack-no-clear 'vector) arg2 (the-as vector (-> s5-0 best-other-tri)))
)
0.0
)
)
(else
)
)
)
(else
(vector-! (-> s5-0 move-dist) arg1 arg0)
)
)
)
(set! (-> s5-0 start-pos quad) (-> arg0 quad))
(let ((v1-14 s5-0))
(set! (-> v1-14 radius) f30-0)
(set! (-> v1-14 collide-with) (collide-spec enemy hit-by-player-list hit-by-others-list))
(set! (-> v1-14 ignore-process0) this)
(set! (-> v1-14 ignore-process1) (handle->process (-> this focus handle)))
(set! (-> v1-14 ignore-pat) (new 'static 'pat-surface :noentity #x1 :nojak #x1 :probe #x1 :noendlessfall #x1))
(set! (-> v1-14 action-mask) (collide-action solid))
)
)
(cond
((< (fill-and-probe-using-line-sphere *collide-cache* s5-0) 0.0)
#t
)
(else
(when (and (the-as basic (as-type (-> s5-0 best-other-tri collide-ptr) collide-shape-prim))
(< (vector-dot
(-> s5-0 best-other-tri normal)
(vector-! (new 'stack-no-clear 'vector) arg2 (the-as vector (-> s5-0 best-other-tri)))
)
0.0
)
)
)
)
)
)
(none)
)
(defmethod predator-method-184 ((this predator) (arg0 int) (arg1 float))
(rlet ((acc :class vf)
(vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
(vf7 :class vf)
)
(init-vf0-vector)
(let ((a1-1 (-> this node-list data arg0))
(s5-0 (new 'stack-no-clear 'projectile-init-by-other-params))
)
(set! (-> s5-0 ent) (-> this entity))
(set! (-> s5-0 charge) 1.0)
(set! (-> s5-0 options) (projectile-options))
(set! (-> s5-0 notify-handle) (process->handle this))
(set! (-> s5-0 owner-handle) (the-as handle #f))
(set! (-> s5-0 ignore-handle) (process->handle this))
(let* ((v1-10 *game-info*)
(a0-11 (+ (-> v1-10 attack-id) 1))
)
(set! (-> v1-10 attack-id) a0-11)
(set! (-> s5-0 attack-id) a0-11)
)
(set! (-> s5-0 timeout) (seconds 4))
(vector<-cspace! (-> s5-0 pos) a1-1)
(let ((s2-0 (handle->process (-> this focus handle)))
(s3-0 (new 'stack-no-clear 'vector))
)
(when s2-0
(seek! (-> this miss-amount) (* 0.5 (vector-length (-> (the-as process-focusable s2-0) root transv))) 4096.0)
(set! (-> s3-0 quad) (-> (get-trans (the-as process-focusable s2-0) 3) quad))
(let ((sv-224 (new 'stack-no-clear 'vector)))
(let ((v1-24 (-> s5-0 pos))
(a0-18 s3-0)
)
(.lvf vf4 (&-> v1-24 quad))
(.lvf vf5 (&-> a0-18 quad))
)
(.mov.vf.w vf6 vf0)
(.sub.vf.xyz vf6 vf4 vf5)
(.svf (&-> sv-224 quad) vf6)
(let* ((f0-5 (vector-length sv-224))
(f0-6 (/ f0-5 (meters 130)))
(sv-240 (new 'stack-no-clear 'vector))
(s0-0 (new 'stack-no-clear 'vector))
(s1-1 (new 'stack-no-clear 'vector))
)
(let ((a0-19 s3-0))
(let ((v1-30 s3-0))
(let ((a1-6 (-> (the-as process-focusable s2-0) root transv)))
(let ((a2-2 f0-6))
(.mov vf7 a2-2)
)
(.lvf vf5 (&-> a1-6 quad))
)
(.lvf vf4 (&-> v1-30 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 (&-> a0-19 quad) vf6)
)
(vector-normalize! sv-224 1.0)
(vector-flatten! sv-240 *up-vector* sv-224)
(vector-normalize! sv-240 1.0)
(vector-cross! s0-0 sv-224 sv-240)
(vector-normalize! s0-0 1.0)
(let ((a2-5 (quaternion-vector-angle! (new 'stack-no-clear 'quaternion) sv-224 (-> this shoot-angle))))
(vector-orient-by-quat! sv-240 sv-240 a2-5)
)
(let ((a2-7 (quaternion-vector-angle! (new 'stack-no-clear 'quaternion) sv-224 (-> this shoot-angle))))
(vector-orient-by-quat! s0-0 s0-0 a2-7)
)
(let ((a0-29 s1-1))
(let ((v1-32 s3-0))
(let ((a1-17 (-> this miss-amount)))
(.mov vf7 a1-17)
)
(.lvf vf5 (&-> sv-240 quad))
(.lvf vf4 (&-> v1-32 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 (&-> a0-29 quad) vf6)
)
(let ((v1-33 s3-0))
(let ((a0-30 (* arg1 (-> this miss-amount))))
(.mov vf7 a0-30)
)
(.lvf vf5 (&-> s0-0 quad))
(.lvf vf4 (&-> s1-1 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 (&-> v1-33 quad) vf6)
)
)
)
(vector-! (-> s5-0 vel) s3-0 (-> s5-0 pos))
(vector-normalize! (-> s5-0 vel) 409600.0)
(vector-normalize! (-> s5-0 vel) 532480.0)
(spawn-projectile predator-shot s5-0 this *default-dead-pool*)
)
)
)
0
(none)
)
)
(set! (-> *lightning-spec-id-table* 18) (new 'static 'lightning-spec
:name "lightning-predator-shock-skel"
:flags (lightning-spec-flags lsf0)
:rand-func #x2
:start-color (new 'static 'rgba :r #xff :g #xff :b #xff :a #x80)
:end-color (new 'static 'rgba :r #xff :g #xff :b #xff :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 #x83 :page #xc)
:reduction 0.8
:num-points 32
:box-size 2048.0
:merge-factor 0.8
:merge-count 2
:radius 2048.0
:duration 30.0
:sound (static-sound-spec "predator-zap")
)
)
(defmethod predator-method-183 ((this predator))
(cond
((< (-> this hit-points) 2)
(when (!= (-> this dest-fade) 128.0)
(sound-play "pred-uncloak")
(stop! (-> this sound))
(set! (-> this sound) (the-as ambient-sound 0))
0
)
(set! (-> this dest-fade) 128.0)
)
(else
(set! (-> this dest-fade) 0.0)
)
)
(seek! (-> this fade) (-> this dest-fade) (* 60.0 (seconds-per-frame)))
(set! (-> this draw force-fade) (the-as uint (the int (-> this fade))))
(cond
((zero? (-> this draw force-fade))
(setup-masks (-> this draw) 8 0)
(setup-masks (-> this draw) 0 4)
(logclear! (-> this draw status) (draw-control-status force-fade warp-cross-fade))
)
((= (-> this draw force-fade) 128)
(setup-masks (-> this draw) 0 8)
(setup-masks (-> this draw) 4 0)
(logclear! (-> this draw status) (draw-control-status force-fade warp-cross-fade))
)
(else
(setup-masks (-> this draw) 8 0)
(setup-masks (-> this draw) 4 0)
(logior! (-> this draw status) (draw-control-status force-fade warp-cross-fade))
)
)
(if (< 245760.0 (vector-vector-distance (-> this root trans) (camera-pos)))
(setup-masks (-> this draw) 0 8)
)
(when (< (current-time) (the-as time-frame (-> this shock-effect-end)))
(when (time-elapsed? (-> this shock-effect-time) (seconds 0.04))
(set-time! (-> this shock-effect-time))
(process-drawable-shock-skel-effect
this
(-> *lightning-spec-id-table* 18)
lightning-probe-callback
(-> *part-id-table* 166)
2048.0
-1
-1
)
)
)
0
(none)
)
(defstate active (predator)
: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! predator-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 (predator)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(go-virtual hostile)
)
)
(defstate idle (predator)
:virtual #t
:post (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy idle) post)))
(if t9-0
((the-as (function none) t9-0))
)
)
(predator-method-183 self)
)
)
(defstate fire (predator)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(logior! (-> self focus-status) (focus-status dangerous))
(let* ((v1-2 *game-info*)
(v0-0 (+ (-> v1-2 attack-id) 1))
)
(set! (-> v1-2 attack-id) v0-0)
(set! (-> self attack-id) v0-0)
)
)
:exit (behavior ()
(if (logtest? (-> self enemy-flags) (enemy-flag dangerous-backup))
(logior! (-> self focus-status) (focus-status dangerous))
(logclear! (-> self focus-status) (focus-status dangerous))
)
)
:trans (behavior ()
(if (not (handle->process (-> self focus handle)))
(go-virtual active)
)
)
:code (behavior ()
(until #f
1.0
(let ((gp-0 0))
(set! (-> self shoot-angle) (* 182.04445 (rand-vu-float-range -45.0 45.0)))
(ja-channel-push! 1 (seconds 0.2))
(ja-no-eval :group! predator-shoot-guns0-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(when (and (< 9.0 (ja-frame-num 0)) (zero? gp-0))
(set! gp-0 1)
(predator-method-184 self 12 1.0)
)
(when (and (< 11.0 (ja-frame-num 0)) (= gp-0 1))
(set! gp-0 2)
(predator-method-184 self 16 -1.0)
)
(let ((s5-0 (handle->process (-> self focus handle))))
(when s5-0
(seek-toward-heading-vec!
(-> self root)
(vector-! (new 'stack-no-clear 'vector) (get-trans (the-as process-focusable s5-0) 0) (-> self root trans))
32768.0
(seconds 0.05)
)
(if (< (vector-vector-distance (-> self root trans) (get-trans (the-as process-focusable s5-0) 0)) 24576.0)
(go-virtual close-attack)
)
)
)
(suspend)
(ja :num! (seek!))
)
)
(b! #t cfg-26 :delay (nop!))
)
(the-as none #f)
(label cfg-26)
(go-virtual hide)
)
:post enemy-simple-post
)
(defstate close-attack (predator)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(set-dangerous! self #t)
(logior! (-> self enemy-flags) (enemy-flag lock-focus))
(logior! (-> self focus-status) (focus-status dangerous))
(let* ((v1-6 *game-info*)
(a0-3 (+ (-> v1-6 attack-id) 1))
)
(set! (-> v1-6 attack-id) a0-3)
(set! (-> self attack-id) a0-3)
)
(let ((v1-7 (-> self nav)))
(set! (-> v1-7 target-speed) 0.0)
)
0
)
:exit (behavior ()
(set-dangerous! self #f)
(if (logtest? (-> self enemy-flags) (enemy-flag dangerous-backup))
(logior! (-> self focus-status) (focus-status dangerous))
(logclear! (-> self focus-status) (focus-status dangerous))
)
)
:code (behavior ()
(ja-channel-push! 1 (seconds 0.2))
(ja-no-eval :group! predator-close-attack-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
(let ((v1-25 (-> self nav state)))
(set! (-> v1-25 speed) 0.0)
)
0
(ja-no-eval :group! predator-close-attack-recover-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
(if (zero? (rnd-int-count self 3))
(sound-play "pred-talk")
)
(go-virtual hostile)
)
:post nav-enemy-chase-post
)
(defstate hidden (predator)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(set-time! (-> self state-time))
(let ((v1-2 self))
(set! (-> v1-2 enemy-flags) (the-as enemy-flag (logclear (-> v1-2 enemy-flags) (enemy-flag enemy-flag36))))
(set! (-> v1-2 nav callback-info) *nav-enemy-null-callback-info*)
)
0
(set! (-> self next-change)
(the-as uint (+ (current-time) (the int (* 300.0 (rand-vu-float-range 2.0 5.0)))))
)
)
:trans (behavior ()
(predator-method-186 self)
(let ((a0-1 (-> self nav state))
(v1-3 (-> self hide-pos))
)
(logclear! (-> a0-1 flags) (nav-state-flag directional-mode))
(logior! (-> a0-1 flags) (nav-state-flag target-poly-dirty))
(set! (-> a0-1 target-post quad) (-> v1-3 quad))
)
0
(let ((gp-0 (handle->process (-> self focus handle))))
(if (not gp-0)
(go-virtual active)
)
(when gp-0
(if (< (vector-vector-xz-distance (get-trans (the-as process-focusable gp-0) 0) (-> self root trans)) 49152.0)
(go-virtual hostile)
)
)
)
(if (< (the-as time-frame (-> self next-change)) (current-time))
(go-virtual hide)
)
)
:code (behavior ()
(until #f
(ja-channel-push! 1 (seconds 0.2))
(until (logtest? (-> self nav state flags) (nav-state-flag at-target))
(ja-no-eval :group! predator-run0-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
(ja-channel-push! 1 (seconds 0.2))
(until (not (logtest? (-> self nav state flags) (nav-state-flag at-target)))
(ja-no-eval :group! predator-idle-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
)
#f
)
:post (behavior ()
(nav-enemy-method-176 self)
)
)
(defstate hide (predator)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(set-time! (-> self state-time))
(nav-enemy-method-166 self)
(let ((v1-4 self))
(if (not (logtest? (enemy-flag enemy-flag36) (-> v1-4 enemy-flags)))
(set! (-> v1-4 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag38) (-> v1-4 enemy-flags))))
)
(set! (-> v1-4 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag36) (-> v1-4 enemy-flags))))
(set! (-> v1-4 nav callback-info) (-> v1-4 enemy-info callback-info))
)
0
(predator-method-187 self)
(set! (-> self next-change) (the-as uint 0))
0
)
:trans (behavior ()
(let ((gp-0 (handle->process (-> self focus handle))))
(if (not gp-0)
(go-virtual active)
)
(when gp-0
(if (< (vector-vector-xz-distance (get-trans (the-as process-focusable gp-0) 0) (-> self root trans)) 65536.0)
(go-virtual hostile)
)
(if (and (time-elapsed? (-> self state-time) (seconds 0.5))
(check-los? (-> self los) 0)
(not (logtest? (-> self draw status) (draw-control-status on-screen)))
)
(go-virtual fire)
)
)
)
(predator-method-186 self)
(let ((a0-12 (-> self nav state))
(v1-30 (-> self hide-pos))
)
(logclear! (-> a0-12 flags) (nav-state-flag directional-mode))
(logior! (-> a0-12 flags) (nav-state-flag target-poly-dirty))
(set! (-> a0-12 target-post quad) (-> v1-30 quad))
)
0
(if (and (time-elapsed? (-> self state-time) (seconds 0.5))
(logtest? (-> self nav state flags) (nav-state-flag at-target))
)
(go-virtual hidden)
)
)
:code (behavior ()
(ja-channel-push! 1 (seconds 0.2))
(until #f
(ja-no-eval :group! predator-run0-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
#f
)
:post (behavior ()
(nav-enemy-method-176 self)
)
)
(defstate hostile (predator)
:virtual #t
:enter (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy hostile) enter)))
(if t9-0
(t9-0)
)
)
(set! (-> self want-stop) #f)
(set-time! (-> self state-time))
(set! (-> self next-change)
(the-as uint (+ (current-time) (the int (* 300.0 (rand-vu-float-range 4.0 8.0)))))
)
(if (zero? (rnd-int-count self 3))
(sound-play "pred-talk")
)
)
:trans (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy hostile) trans)))
(if t9-0
(t9-0)
)
)
(if (time-elapsed? (-> self state-time) (seconds 5))
(go-virtual hide)
)
(let ((gp-0 (handle->process (-> self focus handle))))
(if (not gp-0)
(go-virtual active)
)
(when (get-enemy-target self)
(when (and gp-0 (time-elapsed? (-> self state-time) (-> self reaction-time)))
(let ((f0-0 (vector-vector-xz-distance (get-trans (the-as process-focusable gp-0) 0) (-> self root trans))))
(cond
((< f0-0 16384.0)
(go-virtual close-attack)
)
((< 57344.0 f0-0)
(go-virtual hide)
)
)
)
)
)
)
)
:code (behavior ()
(ja-channel-push! 1 (seconds 0.2))
(ja-no-eval :group! predator-run0-ja :num! (seek!) :frame-num 6.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
(until #f
(ja-no-eval :group! predator-run0-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))
)
)
#f
)
)
;; WARN: Return type mismatch symbol vs none.
(defmethod predator-method-186 ((this predator))
(rlet ((acc :class vf)
(vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
(vf7 :class vf)
)
(init-vf0-vector)
(let ((f30-0 0.0)
(s5-0 -1)
(s4-0 (-> *predator-graph* node (-> this curr-node)))
)
(dotimes (s3-0 32)
(when (logtest? (the-as int (-> s4-0 points)) (ash 1 s3-0))
(let ((s1-0 (new 'stack-no-clear 'vector))
(s2-0 (new 'stack-no-clear 'vector))
)
(vector-rotate-around-y! s1-0 *x-vector* (* 182.04445 (* 11.25 (the float s3-0))))
(let ((a0-6 s2-0))
(let ((v1-7 (-> s4-0 position)))
(let ((a1-3 (-> s4-0 radius)))
(.mov vf7 a1-3)
)
(.lvf vf5 (&-> s1-0 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 (&-> a0-6 quad) vf6)
)
(let ((f0-3 (vector-vector-distance (target-pos 0) s2-0)))
(when (or (= s5-0 -1) (< f30-0 f0-3))
(set! s5-0 s3-0)
(set! f30-0 f0-3)
(set! (-> this hide-pos quad) (-> s2-0 quad))
)
)
)
)
)
)
(none)
)
)
(defmethod predator-method-185 ((this predator))
(let ((f30-0 0.0)
(s5-0 -1)
)
-1
(dotimes (s4-0 (the-as int (-> *predator-graph* node-count)))
(let* ((s3-0 (-> *predator-graph* node s4-0))
(f0-0 (vector-vector-distance (-> s3-0 position) (-> this root trans)))
)
(when (and (not (logtest? (-> s3-0 flags) (predator-node-flag taken))) (or (= s5-0 -1) (< f0-0 f30-0)))
(set! f30-0 f0-0)
(set! s5-0 s4-0)
)
)
)
(set! (-> this curr-node) s5-0)
(logior! (-> *predator-graph* node s5-0 flags) (predator-node-flag taken))
)
(predator-method-186 this)
(none)
)
(defmethod predator-method-187 ((this predator))
(let* ((s5-0 (-> *predator-graph* node (-> this curr-node)))
(s4-0 (rand-vu-int-count (-> s5-0 edge-count)))
)
(dotimes (s3-0 (-> s5-0 edge-count))
(let* ((s2-0
(-> (the-as (pointer uint16) (+ (* (+ (-> s5-0 edge-index) (mod (+ s3-0 s4-0) (-> s5-0 edge-count))) 16)
(the-as int (-> *predator-graph* edge))
)
)
)
)
(s1-0 (-> *predator-graph* node s2-0))
)
(when (and (not (point-in-line-region? (target-pos 0) (-> s5-0 position) (-> s1-0 position) 61440.0))
(not (logtest? (-> s1-0 flags) (predator-node-flag taken)))
)
(logior! (-> s1-0 flags) (predator-node-flag taken))
(logclear! (-> s5-0 flags) (predator-node-flag taken))
(set! (-> this curr-node) (the-as int s2-0))
(return #t)
)
)
)
)
#f
)
(defmethod common-post ((this predator))
"Does a lot of various things relating to interacting with the target
- tracks when the enemy was last drawn
- looks at the target and handles attacking
@TODO Not extremely well understood yet"
(let ((t9-0 (method-of-type nav-enemy common-post)))
(t9-0 this)
)
(predator-method-183 this)
(los-control-method-9 (-> this los) (the-as process-focusable #f) (the-as vector #f) 2048.0)
(when (nonzero? (-> this sound))
(update-trans! (-> this sound) (-> this root trans))
(update! (-> this sound))
)
(none)
)
(defmethod set-dangerous! ((this predator) (arg0 symbol))
(let ((v1-1 (-> this root root-prim)))
(dotimes (a0-1 (the-as int (-> v1-1 specific 0)))
(let ((a2-1 (-> (the-as collide-shape-prim-group v1-1) child a0-1)))
(if arg0
(logior! (-> a2-1 prim-core action) (collide-action deadly))
(logclear! (-> a2-1 prim-core action) (collide-action deadly))
)
)
)
)
#f
)
(defmethod init-enemy-collision! ((this predator))
"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 5) 0)))
(set! (-> s5-0 total-prims) (the-as uint 6))
(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 no-standon))
(set-vector! (-> s4-0 local-sphere) 0.0 11264.0 0.0 17203.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 enemy))
(set! (-> v1-13 prim-core collide-with) (collide-spec jak bot crate hit-by-others-list player-list))
(set! (-> v1-13 prim-core action) (collide-action solid))
(set-vector! (-> v1-13 local-sphere) 0.0 5120.0 0.0 5120.0)
)
(let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
(set! (-> v1-15 prim-core collide-as) (collide-spec enemy))
(set! (-> v1-15 prim-core collide-with) (collide-spec jak bot player-list))
(set! (-> v1-15 transform-index) 16)
(set-vector! (-> v1-15 local-sphere) 0.0 0.0 0.0 3276.8)
)
(let ((v1-17 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
(set! (-> v1-17 prim-core collide-as) (collide-spec enemy))
(set! (-> v1-17 prim-core collide-with) (collide-spec jak bot player-list))
(set! (-> v1-17 transform-index) 12)
(set-vector! (-> v1-17 local-sphere) 0.0 0.0 0.0 3276.8)
)
(let ((v1-19 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
(set! (-> v1-19 prim-core collide-as) (collide-spec enemy))
(set! (-> v1-19 prim-core collide-with) (collide-spec jak bot player-list))
(set! (-> v1-19 prim-core action) (collide-action solid no-standon))
(set-vector! (-> v1-19 local-sphere) 0.0 9216.0 0.0 5120.0)
)
(let ((v1-21 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
(set! (-> v1-21 prim-core collide-with) (collide-spec backgnd obstacle hit-by-others-list))
(set! (-> v1-21 prim-core action) (collide-action solid))
(set-vector! (-> v1-21 local-sphere) 0.0 12288.0 0.0 12288.0)
)
(set! (-> s5-0 nav-radius) 6144.0)
(let ((v1-23 (-> s5-0 root-prim)))
(set! (-> s5-0 backup-collide-as) (-> v1-23 prim-core collide-as))
(set! (-> s5-0 backup-collide-with) (-> v1-23 prim-core collide-with))
)
(set! (-> s5-0 max-iteration-count) (the-as uint 3))
(set! (-> this root) s5-0)
)
0
(none)
)
(defmethod relocate ((this predator) (offset int))
(call-parent-method this offset)
)
(defmethod nav-enemy-method-167 ((this predator))
(let ((v1-0 (-> this nav)))
(set! (-> v1-0 target-speed) 0.0)
)
0
(let ((v1-2 (-> this nav)))
(set! (-> v1-2 acceleration) (-> this enemy-info walk-acceleration))
)
0
0
(none)
)
(defmethod run-logic? ((this predator))
"Should this process be run? Checked by execute-process-tree."
#t
)
;; WARN: Return type mismatch none vs symbol.
(defmethod enemy-method-63 ((this predator) (arg0 process-focusable) (arg1 enemy-aware))
(let ((t9-0 (method-of-type nav-enemy enemy-method-63)))
(the-as symbol (if (t9-0 this arg0 arg1)
(set-dst-proc! (-> this los) (-> this focus handle))
)
)
)
)
;; WARN: Return type mismatch entity-perm-status vs none.
(defmethod init-from-entity! ((this predator) (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"
(process-entity-status! this (entity-perm-status dead) #t)
(none)
)
(defmethod init-enemy-behaviour-and-stats! ((this predator) (arg0 nav-enemy-info))
"Initializes a bunch of enemy fields related to how they should react, how many hitpoints they should have, etc"
(set! (-> arg0 nav-mesh) *default-nav-mesh*)
(let ((t9-0 (method-of-type nav-enemy init-enemy-behaviour-and-stats!)))
(t9-0 this arg0)
)
(logclear! (-> this mask) (process-mask actor-pause))
(logclear! (-> this enemy-flags) (enemy-flag actor-pause-backup))
0
(none)
)
(defmethod init-enemy! ((this predator))
"Common method called to initialize the enemy, typically sets up default field values and calls ancillary helper methods"
(initialize-skeleton
this
(the-as skeleton-group (art-group-get-by-name *level* "skel-predator" (the-as (pointer uint32) #f)))
(the-as pair 0)
)
(init-enemy-behaviour-and-stats! this *predator-nav-enemy-info*)
(let ((v1-5 (-> this nav)))
(set! (-> v1-5 speed-scale) 1.0)
)
0
(set-gravity-length (-> this root dynam) 327680.0)
(add-connection *part-engine* this 8 this 318 (new 'static 'vector :x 1228.8 :y 450.56 :z 983.04 :w 614400.0))
(add-connection
*part-engine*
this
8
this
318
(new 'static 'vector :x -1228.8 :y 450.56 :z 983.04 :w 614400.0)
)
(new-source! (-> this los) this (seconds 0.2) (collide-spec backgnd enemy obstacle))
(setup-masks (-> this draw) 8 0)
(setup-masks (-> this draw) 4 0)
(logior! (-> this draw status) (draw-control-status force-fade warp-cross-fade))
(set! (-> this draw force-fade) (the-as uint 0))
(set! (-> this fade) 0.0)
(set! (-> this dest-fade) 0.0)
(set! (-> this curr-node) -1)
(set! (-> this next-change) (the-as uint 0))
(set! (-> this miss-amount) 16384.0)
(set! (-> this ambient-sound-id) (new 'static 'sound-id))
(predator-method-185 this)
(set! (-> this sound)
(new 'process 'ambient-sound (static-sound-spec "pred-hum" :fo-min 2 :fo-max 30) (-> this root trans))
)
(logior! (-> this enemy-flags) (enemy-flag check-water check-water-backup))
(add-icon! *minimap* this (the-as uint 16) (the-as int #f) (the-as vector #t) 0)
0
(none)
)
(deftype predator-manager (process)
((predator-count uint32)
(predator-h handle 32)
(hud-counter handle)
(actor-group (pointer actor-group))
(actor-group-count int32)
)
(:state-methods
idle
closed
)
(:methods
(predator-manager-method-16 (_type_) none)
)
)
(define *predator-manager* (the-as predator-manager #f))
;; WARN: Return type mismatch process vs predator-manager.
(defmethod relocate ((this predator-manager) (offset int))
(set! *predator-manager* this)
(if *predator-manager*
(set! *predator-manager* (&+ *predator-manager* offset))
)
(the-as predator-manager ((method-of-type process relocate) this offset))
)
(defmethod predator-manager-method-16 ((this predator-manager))
0
(none)
)
(defstate idle (predator-manager)
:virtual #t
:enter (behavior ()
(set! (-> self hud-counter) (ppointer->handle (process-spawn hud-predator :init hud-init-by-other :to self)))
)
:exit (behavior ()
(when (-> self hud-counter)
(send-event (handle->process (-> self hud-counter)) 'hide-and-die)
(set! (-> self hud-counter) (the-as handle #f))
)
)
:trans (behavior ()
(predator-manager-method-16 self)
(let ((gp-0 0))
(dotimes (v1-2 (the-as int (-> self predator-count)))
(if (handle->process (-> self predator-h v1-2))
(+! gp-0 1)
)
)
(dotimes (s5-0 (length (-> self actor-group 0)))
(if (not (logtest? (-> self actor-group 0 data s5-0 actor extra perm status) (entity-perm-status dead)))
(+! gp-0 1)
)
)
(set! (-> *game-info* counter) (the float gp-0))
(when (zero? gp-0)
(task-node-close! (game-task-node forest-hunt-resolution))
(when (-> self hud-counter)
(send-event (handle->process (-> self hud-counter)) 'hide-and-die)
(set! (-> self hud-counter) (the-as handle #f))
(talker-spawn-func (-> *talker-speech* 89) *entity-pool* (target-pos 0) (the-as region #f))
)
)
)
)
:code sleep-code
)
(defstate closed (predator-manager)
:virtual #t
:code sleep-code
)
;; WARN: Return type mismatch object vs none.
;; WARN: new jak 2 until loop case, check carefully
(defmethod init-from-entity! ((this predator-manager) (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"
(rlet ((acc :class vf)
(vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
(vf7 :class vf)
)
(init-vf0-vector)
(cond
((task-node-closed? (game-task-node forest-hunt-resolution))
(go (method-of-object this closed))
)
(else
(dotimes (v1-2 (the-as int (-> *predator-graph* node-count)))
(let ((a0-4 (-> *predator-graph* node v1-2)))
(logior! (-> a0-4 flags) (predator-node-flag spawnable))
(logclear! (-> a0-4 flags) (predator-node-flag taken))
)
)
(let* ((sv-16 (new 'static 'res-tag))
(v1-6 (res-lump-data (-> this entity) 'actor-groups pointer :tag-ptr (& sv-16)))
)
(cond
((and v1-6 (nonzero? (-> sv-16 elt-count)))
(set! (-> this actor-group) (the-as (pointer actor-group) v1-6))
(set! (-> this actor-group-count) (the-as int (-> sv-16 elt-count)))
)
(else
(set! (-> this actor-group) (the-as (pointer actor-group) #f))
(set! (-> this actor-group-count) 0)
(go process-drawable-art-error "actor-group predator-manager")
)
)
)
(dotimes (s5-0 (length (-> this actor-group 0)))
(let ((t0-1 (-> this actor-group 0 data s5-0 actor)))
(if t0-1
(add-icon! *minimap* this (the-as uint 16) (the-as int #f) (the-as vector t0-1) 0)
)
)
)
(dotimes (s5-1 (the-as int (-> *predator-graph* node-count)))
(let ((s4-0 (-> *predator-graph* node s5-1)))
(when (logtest? (-> s4-0 flags) (predator-node-flag spawnable))
(dotimes (s3-0 (the-as int (-> *predator-graph* node-count)))
(let ((s2-0 (-> *predator-graph* node s3-0)))
(when (and (!= s5-1 s3-0) (logtest? (-> s2-0 flags) (predator-node-flag spawnable)))
(if (< (vector-vector-distance (-> s4-0 position) (-> s2-0 position)) 180224.0)
(logclear! (-> s2-0 flags) (predator-node-flag spawnable))
)
)
)
)
)
)
)
(let ((s5-2 0))
(dotimes (s4-1 (the-as int (-> *predator-graph* node-count)))
(let ((s3-1 (-> *predator-graph* node s4-1)))
(when (logtest? (-> s3-1 flags) (predator-node-flag spawnable))
(let ((s2-1 (new 'stack-no-clear 'enemy-init-by-other-params)))
(new 'stack-no-clear 'vector)
(let ((s0-0 (new 'stack-no-clear 'vector))
(s1-0 (new 'stack-no-clear 'vector))
)
(let ((v1-52 0))
(until #f
(when (logtest? (-> s3-1 points) (ash 1 v1-52))
(vector-rotate-around-y! s0-0 *x-vector* (* 182.04445 (* 11.25 (the float v1-52))))
(let ((a0-29 s1-0))
(let ((v1-53 (-> s3-1 position)))
(let ((a1-17 (-> s3-1 radius)))
(.mov vf7 a1-17)
)
(.lvf vf5 (&-> s0-0 quad))
(.lvf vf4 (&-> v1-53 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 (&-> a0-29 quad) vf6)
)
(goto cfg-40)
)
(+! v1-52 1)
)
)
#f
(label cfg-40)
(set! (-> s2-1 trans quad) (-> s1-0 quad))
)
(quaternion-copy! (-> s2-1 quat) *unity-quaternion*)
(set! (-> s2-1 entity) (-> this actor-group 1 data s5-2 actor))
(set! (-> s2-1 directed?) #f)
(set! (-> s2-1 no-initial-move-to-ground?) #f)
(let ((s2-2
(the-as process (as-type
(ppointer->process (process-spawn predator :init enemy-init-by-other this s2-1 :to this))
process-focusable
)
)
)
(v1-66 (as-type (entity-nav-mesh-by-aid (the-as actor-id (-> s3-1 nav-mesh-id))) entity-nav-mesh))
)
(set! (-> this predator-h (-> this predator-count)) (process->handle s2-2))
(+! (-> this predator-count) 1)
(when v1-66
(change-to (-> v1-66 nav-mesh) (the-as process-drawable s2-2))
(let ((v1-70 (-> (the-as process-drawable s2-2) nav state)))
(set! (-> v1-70 current-poly) (the-as nav-poly #f))
)
0
)
)
)
(+! s5-2 1)
)
)
)
)
(go (method-of-object this idle))
)
)
(none)
)
)