Files
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

1076 lines
38 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: fodder.gc
;; name in dgo: fodder
;; dgos: ATO, SEB, SWB, RUI
;; DECOMP BEGINS
(defskelgroup skel-fodder fodder fodder-lod0-jg -1
((fodder-lod0-mg (meters 20)) (fodder-lod1-mg (meters 999999)))
:bounds (static-spherem 0 0 0 2)
:shadow fodder-shadow-mg
:origin-joint-index 12
)
(deftype fodder-anim-info (structure)
((anim-index int32)
)
:pack-me
)
(deftype fodder-global-info (basic)
((prev-blue-hit int8)
(blue-hit-anim fodder-anim-info 3 :inline)
)
)
(deftype fodder (nav-enemy)
((left-eye joint-mod)
(right-eye joint-mod)
(look-at-other handle)
(neck-away-from symbol)
(look-at-other-time time-frame)
(pad-iuj1n23i1 uint32 3)
(slow-timer time-frame)
(fast-timer time-frame)
(attack-type uint64)
(test-vec vector :inline)
)
(:methods
(fodder-method-178 (_type_) none)
(look-at-position! (_type_ vector) float)
(fodder-method-180 (_type_) symbol)
(fodder-method-181 (_type_ symbol) none)
(fodder-method-182 (_type_) float)
)
)
(define *fodder-global-info*
(new 'static 'fodder-global-info :blue-hit-anim (new 'static 'inline-array fodder-anim-info 3
(new 'static 'fodder-anim-info :anim-index 18)
(new 'static 'fodder-anim-info :anim-index 19)
(new 'static 'fodder-anim-info :anim-index 20)
)
)
)
(define *fodder-nav-enemy-info*
(new 'static 'nav-enemy-info
:use-die-falling #t
:use-victory #f
:use-jump-blocked #t
: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 #x4 :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame)
(new 'static 'idle-control-frame)
(new 'static 'idle-control-frame)
)
:idle-anim 6
:notice-anim 13
:hostile-anim 7
:hit-anim 13
:knocked-anim 16
:knocked-land-anim 17
:die-anim 14
:die-falling-anim 21
:victory-anim 6
:jump-wind-up-anim 7
:jump-in-air-anim 7
:jump-land-anim 7
:neck-joint 5
:look-at-joint 5
:bullseye-joint 4
:sound-hit (static-sound-name "fodder-hit")
:sound-die (static-sound-name "fodder-die")
:notice-distance (meters 40)
:notice-distance-delta (meters 10)
:proximity-notice-distance (meters 40)
:default-hit-points 1
:gnd-collide-with (collide-spec backgnd)
:overlaps-others-collide-with-filter (collide-spec jak bot player-list)
:penetrate-knocked (penetrate
generic-attack
flop
punch
spin
roll
uppercut
bonk
tube
vehicle
flut-attack
board
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
knocked
)
:movement-gravity (meters -100)
:friction 0.8
:attack-shove-back (meters 3)
:attack-shove-up (meters 2)
:attack-mode 'generic
:attack-damage 1
: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 -1
:gem-offset (new 'static 'sphere :r 163840.0)
:callback-info #f
:use-momentum #f
:use-frustration #t
:use-stop-chase #f
:use-circling #t
:use-pacing #t
:walk-anim 12
:turn-anim 7
:run-anim 7
:taunt-anim -1
:run-travel-speed (meters 7.5)
:run-acceleration (meters 1)
:run-turning-acceleration (meters 100)
:walk-travel-speed (meters 4)
:walk-acceleration (meters 1)
:walk-turning-acceleration (meters 3)
:maximum-rotation-rate (degrees 360)
:notice-nav-radius (meters 1.5)
: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! (-> *fodder-nav-enemy-info* fact-defaults) *fact-info-enemy-defaults*)
(defmethod look-at-target! ((this fodder) (arg0 enemy-flag))
"Logic for looking at the target that is locked on, sets some flags and adjusts the neck to look at the target if available
@param flag Reacts to [[enemy-flag::death-start]] and [[enemy-flag::enable-on-active]], see implementation for details"
(let ((parent-method (method-of-type nav-enemy look-at-target!)))
(parent-method this arg0)
)
(if (nonzero? (-> this left-eye))
(mode-set! (-> this left-eye) (joint-mod-mode polar-look-at))
)
(if (nonzero? (-> this right-eye))
(mode-set! (-> this right-eye) (joint-mod-mode polar-look-at))
)
0
(none)
)
(defmethod stop-looking-at-target! ((this fodder))
"Will unset [[enemy-flag::death-start]] and [[enemy-flag::lock-focus]] and call [[joint-mod::shut-down]] if applicable"
(let ((parent-method (method-of-type nav-enemy stop-looking-at-target!)))
(parent-method this)
)
(if (nonzero? (-> this left-eye))
(shut-down (-> this left-eye))
)
(if (nonzero? (-> this right-eye))
(shut-down (-> this right-eye))
)
0
(none)
)
(defmethod look-at-position! ((this fodder) (position vector))
"Adjusts the eyes to look at particular position, or the focused target
@param position If this is provided, it will be used with [[joint-mod::target-set!]] to adjust the eyes, otherwise the `focus` position is used
@return TODO - unsure what the return value is, but it seems to make the eyes more lazy"
(when (not position)
(let ((focus-proc (handle->process (-> this focus handle))))
(if focus-proc
(set! position (get-trans (the-as process-focusable focus-proc) 2))
(return 0.0)
)
)
)
(when (nonzero? (-> this left-eye))
(target-set! (-> this left-eye) position)
(when (nonzero? (-> this left-eye))
(set! (-> this left-eye polar-external-tilt-max) (-> this right-eye polar-internal-tilt-max))
(set! (-> this left-eye polar-external-radius) (-> this right-eye polar-internal-radius))
)
)
(when (nonzero? (-> this right-eye))
(target-set! (-> this right-eye) position)
(when (nonzero? (-> this right-eye))
(set! (-> this right-eye polar-external-tilt-max) (-> this left-eye polar-internal-tilt-max))
(set! (-> this right-eye polar-external-radius) (-> this left-eye polar-internal-radius))
)
)
)
(defmethod fodder-method-180 ((this fodder))
"@TODO no idea, never seems to do anything because the actor-group-count is always 0"
(when (time-elapsed? (-> this look-at-other-time) (seconds 0.25))
(dotimes (group-idx (-> this actor-group-count))
(let ((group (-> this actor-group group-idx)))
(dotimes (actor-idx (-> group length))
(let ((fodder-proc (as-type (-> group data actor-idx actor extra process) fodder)))
(when (and fodder-proc (!= fodder-proc this) (time-elapsed? (-> fodder-proc look-at-other-time) (seconds 0.25)))
(let* ((dir-to-other-fodder
(vector-! (new 'stack-no-clear 'vector) (-> fodder-proc root trans) (-> this root trans))
)
(dir-length (vector-length dir-to-other-fodder))
)
(when (< dir-length 8192.0)
(vector-float*! dir-to-other-fodder dir-to-other-fodder (/ 1.0 dir-length))
(let ((f30-0 (vector-dot
dir-to-other-fodder
(-> (quaternion->matrix (new 'stack-no-clear 'matrix) (-> this root quat)) vector 2)
)
)
)
(when (< (cos 14563.556) f30-0)
(let ((channel (ja-channel-float! (the-as art-joint-anim (-> this draw art-group data 15)) 0.0 0.0 0.0)))
(when channel
(set! (-> this skel interp-select 0) #xe00010)
(set! (-> this skel interp-select 1) 0)
(set! (-> channel param 0) 1.0)
(set! (-> channel param 1) 1.0)
(set! (-> channel param 2) 1.0)
(set! (-> channel num-func) num-func-interp1-play!)
)
)
(set-time! (-> this look-at-other-time))
(set! (-> this look-at-other) (process->handle fodder-proc))
(set! (-> this neck-away-from) #f)
(set-time! (-> fodder-proc look-at-other-time))
(set! (-> fodder-proc look-at-other) (process->handle this))
(set! (-> fodder-proc neck-away-from) #t)
)
)
)
)
)
)
)
)
)
#f
)
)
;; WARN: Return type mismatch object vs none.
(defmethod common-post ((this fodder))
"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 ((parent-method (method-of-type nav-enemy common-post)))
(parent-method this)
)
(let ((proc (the-as process-drawable #f)))
(cond
((and (not (time-elapsed? (-> this look-at-other-time) (seconds 0.5)))
(begin (set! proc (as-type (handle->process (-> this look-at-other)) process-drawable)) proc)
)
(let ((s5-1 (vector<-cspace! (new 'static 'vector) (-> proc node-list data 5))))
(look-at-position! this s5-1)
(cond
((zero? (-> this neck))
)
((-> this neck-away-from)
(let ((s4-0 (new 'static 'vector)))
(let ((v1-11 (vector<-cspace! (new 'static 'vector) (-> this node-list data 5))))
(vector-! s4-0 v1-11 s5-1)
(vector+! s4-0 s4-0 v1-11)
)
(target-set! (-> this neck) s4-0)
)
)
(else
(target-set! (-> this neck) s5-1)
)
)
)
)
((logtest? (-> this enemy-flags) (enemy-flag look-at-focus))
(look-at-position! this (the-as vector #f))
)
)
)
(none)
)
(defstate idle (fodder)
:virtual #t
:post (behavior ()
(let ((func (-> (method-of-type nav-enemy idle) post)))
(if func
((the-as (function none) func))
)
)
(update-transforms (-> self root))
)
)
(defstate active (fodder)
:virtual #t
:enter (behavior ()
(let ((func (-> (method-of-type nav-enemy active) enter)))
(if func
(func)
)
)
(logclear! (-> self enemy-flags) (enemy-flag notice alert cam-attack-mode))
)
:code (behavior ()
(let ((f30-0 (rnd-float-range self 0.9 1.1)))
(until #f
(ja-no-eval :group! (-> self draw art-group data (-> self enemy-info walk-anim))
:num! (seek! max f30-0)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
(when (rnd-go-idle? self 0.8)
(let ((_self self))
(set! (-> _self enemy-flags) (the-as enemy-flag (logclear (-> _self enemy-flags) (enemy-flag enemy-flag36))))
(set! (-> _self nav callback-info) *nav-enemy-null-callback-info*)
)
0
(set-time! (-> self state-time))
(until (not #f)
(ja-no-eval :num! (loop!))
(ja-channel-push! 1 (seconds 0.25))
(ja-no-eval :group! fodder-idle-ja :num! (seek! max f30-0) :frame-num 0.0)
(until (ja-done? 0)
(ja-blend-eval)
(suspend)
(ja :num! (seek! max f30-0))
)
(ja-no-eval :num! (loop!))
(ja-channel-push! 1 (seconds 0.25))
(dotimes (num-chews (rand-vu-int-range 4 7))
(ja-no-eval :group! fodder-chew-ja :num! (seek! max f30-0) :frame-num 0.0)
(until (ja-done? 0)
(ja-blend-eval)
(suspend)
(ja :num! (seek! max f30-0))
)
)
)
(let ((__self self))
(if (not (logtest? (enemy-flag enemy-flag36) (-> __self enemy-flags)))
(set! (-> __self enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag38) (-> __self enemy-flags))))
)
(set! (-> __self enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag36) (-> __self enemy-flags))))
(set! (-> __self nav callback-info) (-> __self enemy-info callback-info))
)
0
(ja-no-eval :num! (loop!))
(ja-channel-push! 1 (seconds 0.25))
(ja-no-eval :group! (-> self draw art-group data (-> self enemy-info walk-anim))
:num! (seek! max f30-0)
:frame-num 0.0
)
(until (ja-done? 0)
(ja-blend-eval)
(suspend)
(ja :num! (seek! max f30-0))
)
)
)
)
#f
)
)
(defstate notice (fodder)
: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))
)
(stop-looking-at-target! self)
(if (nonzero? (-> self neck))
(mode-set! (-> self neck) (joint-mod-mode look-at))
)
(if (nonzero? (-> self left-eye))
(mode-set! (-> self left-eye) (joint-mod-mode polar-look-at))
)
(if (nonzero? (-> self right-eye))
(mode-set! (-> self right-eye) (joint-mod-mode polar-look-at))
)
(let* ((s5-0 0)
(f28-0 0.5)
(v1-18 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
(v1-19 (the-as number (logior #x3f800000 v1-18)))
(s4-0 (< f28-0 (+ -1.0 (the-as float v1-19))))
)
(ja-no-eval :group! (-> self draw art-group data (-> self enemy-info notice-anim))
:num! (seek! max (* 2.0 f30-0))
:frame-num 0.0
)
(until (ja-done? 0)
(if (< (vector-length (vector-! (new 'stack-no-clear 'vector) (target-pos 0) (-> self root trans))) 12288.0)
(goto cfg-22)
)
(set! s5-0 (- (the-as time-frame s5-0) (- (current-time) (-> self clock old-frame-counter))))
(when (<= s5-0 0)
(set! s5-0 (rand-vu-int-range 75 150))
(set! s4-0 (not s4-0))
(let ((s3-2 (new 'stack-no-clear 'matrix)))
(quaternion->matrix s3-2 (-> self root quat))
(let* ((f28-1 0.5)
(f26-0 8.0)
(v1-56 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
(v1-57 (the-as number (logior #x3f800000 v1-56)))
(v1-59 (+ f28-1 (* f26-0 (+ -1.0 (the-as float v1-57)))))
)
(if s4-0
(set! v1-59 (- v1-59))
)
(vector+float*! gp-0 (-> s3-2 vector 2) (-> s3-2 vector 0) v1-59)
)
(vector-normalize! gp-0 16384.0)
(vector+float*! gp-0 gp-0 (-> s3-2 vector 1) (rand-vu-float-range 5079.04 7168.0))
)
(vector+! gp-0 gp-0 (-> self root trans))
)
(if (nonzero? (-> self neck))
(target-set! (-> self neck) gp-0)
)
(look-at-position! self gp-0)
(suspend)
(ja :num! (seek! max (* 2.0 f30-0)))
)
)
)
(label cfg-22)
(rnd-float-range self 0.8 1.2)
(new 'stack-no-clear 'vector)
(look-at-target! self (enemy-flag look-at-focus))
(stop-looking-at-target! self)
(if (nonzero? (-> self left-eye))
(shut-down (-> self left-eye))
)
(if (nonzero? (-> self right-eye))
(shut-down (-> self right-eye))
)
(let ((gp-1 (-> self focus aware)))
(cond
((and (= gp-1 (enemy-aware enemy-aware-3)) (get-enemy-target self))
(go-hostile self)
)
((>= 1 (the-as int gp-1))
(go-virtual active)
)
(else
(go-stare self)
)
)
)
)
)
(defmethod fodder-method-182 ((this fodder))
(ja-channel-push! 2 (seconds 0.2))
(let ((s5-0 (-> this skel root-channel 0)))
(joint-control-channel-group-eval!
s5-0
(the-as art-joint-anim (-> this draw art-group data (-> this enemy-info hostile-anim)))
num-func-identity
)
(set! (-> s5-0 frame-num) 0.0)
)
(let ((s5-1 (-> this skel root-channel 1)))
(let* ((v1-10 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
(v1-11 (the-as number (logior #x3f800000 v1-10)))
(f0-3 (+ -1.0 (the-as float v1-11)))
)
(set! (-> s5-1 frame-interp 1) f0-3)
(set! (-> s5-1 frame-interp 0) f0-3)
)
(joint-control-channel-group-eval!
s5-1
(the-as art-joint-anim (-> this draw art-group data 8))
num-func-identity
)
(set! (-> s5-1 frame-num) 0.0)
)
)
(defstate hostile (fodder)
:virtual #t
:enter (behavior ()
(let ((func (-> (method-of-type nav-enemy hostile) enter)))
(if func
(func)
)
)
(fodder-method-181 self #t)
(set! (-> self slow-timer) 0)
(set! (-> self fast-timer) 0)
0
)
:exit (behavior ()
;; og:preserve-this fix potential use-after-free bug
(if (-> self nav)
(let ((v1-0 (-> self nav)))
(set! (-> v1-0 target-speed) (-> self enemy-info run-travel-speed))
))
0
;; og:preserve-this fix potential use-after-free bug
(if (-> self nav)
(let ((v1-2 (-> self nav)))
(set! (-> v1-2 turning-acceleration) (-> self enemy-info run-turning-acceleration))
))
0
(fodder-method-181 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))
)
)
:trans (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy hostile) trans)))
(if t9-0
(t9-0)
)
)
(fodder-method-180 self)
(let ((a0-2 (handle->process (-> self focus handle))))
(when a0-2
(set! (-> self focus-pos quad) (-> (get-trans (the-as process-focusable a0-2) 0) quad))
(let ((f30-0 (vector-vector-xz-distance-squared (-> self focus-pos) (-> self root trans))))
(when (and (< f30-0 (square 24576.0)) (zero? (-> self slow-timer)))
(let ((v1-20 (-> self nav)))
(set! (-> v1-20 target-speed) 0.0)
)
0
(let ((v1-22 (-> self nav)))
(set! (-> v1-22 turning-acceleration) 0.0)
)
0
(set-time! (-> self slow-timer))
(ja-channel-push! 1 (seconds 0.08))
(ja :group! (-> self draw art-group data (-> self enemy-info idle-anim)))
(ja :num-func num-func-identity :frame-num 0.0)
(if (logtest? (-> self enemy-flags) (enemy-flag dangerous-backup))
(logior! (-> self focus-status) (focus-status dangerous))
(logclear! (-> self focus-status) (focus-status dangerous))
)
(let* ((v1-40 (/ (the-as int (rand-uint31-gen *random-generator*)) 256))
(v1-41 (the-as number (logior #x3f800000 v1-40)))
)
(if (< (+ -1.0 (the-as float v1-41)) 0.5)
(set! (-> self attack-type) (the-as uint 1))
(set! (-> self attack-type) (the-as uint 2))
)
)
)
(when (and (nonzero? (-> self slow-timer))
(zero? (-> self fast-timer))
(time-elapsed? (-> self slow-timer) (seconds 0.35))
)
(set-time! (-> self fast-timer))
(ja-channel-push! 1 (seconds 0.02))
(let ((v1-55 (-> self attack-type)))
(cond
((zero? v1-55)
(ja :group! (-> self draw art-group data (-> self enemy-info hostile-anim)))
)
((= v1-55 1)
(ja :group! fodder-jump-chomp-ja)
(logior! (-> self focus-status) (focus-status dangerous))
(let* ((v1-64 *game-info*)
(a0-30 (+ (-> v1-64 attack-id) 1))
)
(set! (-> v1-64 attack-id) a0-30)
(set! (-> self attack-id) a0-30)
)
)
(else
(ja :group! fodder-jump-kick-ja)
(logior! (-> self focus-status) (focus-status dangerous))
(let* ((v1-70 *game-info*)
(a0-35 (+ (-> v1-70 attack-id) 1))
)
(set! (-> v1-70 attack-id) a0-35)
(set! (-> self attack-id) a0-35)
)
)
)
)
(ja :num-func num-func-identity :frame-num 0.0)
)
(when (nonzero? (-> self fast-timer))
(let ((s5-0
(vector-normalize! (vector-! (new 'stack-no-clear 'vector) (-> self focus-pos) (-> self root trans)) 1.0)
)
(gp-1 (new 'stack-no-clear 'vector))
)
(set! (-> gp-1 quad)
(-> (quaternion->matrix (new 'stack-no-clear 'matrix) (-> self root quat)) vector 2 quad)
)
(let* ((f0-11 (acos (vector-dot s5-0 gp-1)))
(v1-81 (-> self attack-type))
(v1-82 (cond
((zero? v1-81)
300
)
((= v1-81 1)
120
)
(else
120
)
)
)
)
(cond
((time-elapsed? (-> self fast-timer) v1-82)
(set! (-> self slow-timer) 0)
(set! (-> self fast-timer) 0)
(let ((v1-83 (-> self nav)))
(set! (-> v1-83 target-speed) (-> self enemy-info run-travel-speed))
)
0
(let ((v1-85 (-> self nav)))
(set! (-> v1-85 turning-acceleration) (-> self enemy-info run-turning-acceleration))
)
0
(let ((v1-89 (ja-group)))
(if (not (and v1-89 (= v1-89 (-> self draw art-group data (-> self enemy-info hostile-anim)))))
(fodder-method-182 self)
)
)
(go-virtual circling)
)
((< f0-11 3640.889)
(let ((v1-99 (-> self nav)))
(set! (-> v1-99 target-speed) (* 2.5 (-> self enemy-info run-travel-speed)))
)
0
(let ((v1-101 (-> self nav)))
(set! (-> v1-101 turning-acceleration) (* 2.5 (-> self enemy-info run-turning-acceleration)))
)
0
)
(else
(let ((v1-103 (-> self nav)))
(set! (-> v1-103 target-speed) (-> self enemy-info run-travel-speed))
)
0
(let ((v1-105 (-> self nav)))
(set! (-> v1-105 turning-acceleration) (-> self enemy-info run-turning-acceleration))
)
0
)
)
)
)
)
(when (zero? (-> self attack-type))
(when (and (< f30-0 (square 20480.0)) (time-elapsed? (-> self look-at-other-time) (seconds 0.125)))
(let ((v1-117 (ja-channel-float! (the-as art-joint-anim fodder-snap-ja) 0.0 0.0 0.0)))
(when v1-117
(set! (-> self skel interp-select 0) #xe00010)
(set! (-> self skel interp-select 1) 0)
(set! (-> v1-117 param 0) 1.0)
(set! (-> v1-117 param 1) 1.0)
(set! (-> v1-117 param 2) 1.0)
(set! (-> v1-117 num-func) num-func-interp1-play!)
)
)
(set-time! (-> self look-at-other-time))
)
)
)
)
)
)
:code (behavior ()
(fodder-method-182 self)
(let ((f30-0 (rnd-float-range self 0.9 1.1)))
(until #f
(suspend)
(ja :num! (loop! f30-0))
(let ((v1-9 (ja-group)))
(if (and v1-9 (= v1-9 (-> self draw art-group data (-> self enemy-info hostile-anim))))
(ja :chan 1 :num! (chan 0))
)
)
)
)
#f
)
)
(defstate victory (fodder)
:virtual #t
:enter (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy victory) enter)))
(if t9-0
(t9-0)
)
)
(sound-play "fodder-bite" :position (-> self root trans))
)
)
(defstate circling (fodder)
:virtual #t
:code (behavior ()
(let ((v1-2 (ja-group)))
(when (and v1-2 (= v1-2 (-> self draw art-group data (-> self enemy-info walk-anim))))
(ja-no-eval :num! (seek!))
(while (not (ja-done? 0))
(suspend)
(ja-eval)
)
)
)
(until #f
(let ((v1-15 self))
(if (not (logtest? (enemy-flag enemy-flag36) (-> v1-15 enemy-flags)))
(set! (-> v1-15 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag38) (-> v1-15 enemy-flags))))
)
(set! (-> v1-15 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag36) (-> v1-15 enemy-flags))))
(set! (-> v1-15 nav callback-info) (-> v1-15 enemy-info callback-info))
)
0
(let ((v1-18 self))
(set! (-> v1-18 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag37) (-> v1-18 enemy-flags))))
)
0
(let ((v1-20 (-> self nav)))
(set! (-> v1-20 target-speed) 16384.0)
)
0
(let ((v1-22 (-> self nav)))
(set! (-> v1-22 acceleration) (-> self enemy-info run-acceleration))
)
0
(let ((v1-24 (-> self nav)))
(set! (-> v1-24 turning-acceleration) (-> self enemy-info run-turning-acceleration))
)
0
(let ((gp-0 (-> self draw art-group data (-> self enemy-info walk-anim))))
(let ((v1-32 (ja-group)))
(if (not (and v1-32 (= v1-32 gp-0)))
(ja-channel-push! 1 (seconds 0.1))
)
)
(let ((s5-0 (rnd-int-count self 8))
(f30-0 (rnd-float-range self 0.9 1.1))
)
(while (nonzero? s5-0)
(+! s5-0 -1)
(ja-no-eval :group! gp-0 :num! (seek! max f30-0) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
)
)
)
(when (< 20480.0 (vector-vector-xz-distance (-> self focus-pos) (-> self root trans)))
(let ((v1-59 self))
(set! (-> v1-59 enemy-flags) (the-as enemy-flag (logclear (-> v1-59 enemy-flags) (enemy-flag enemy-flag36))))
(set! (-> v1-59 nav callback-info) *nav-enemy-null-callback-info*)
)
0
(let ((v1-62 self))
(set! (-> v1-62 enemy-flags) (the-as enemy-flag (logclear (-> v1-62 enemy-flags) (enemy-flag enemy-flag37))))
)
0
(vector-reset! (-> self root transv))
(let ((v1-68 (ja-group)))
(if (not (and v1-68 (= v1-68 (-> self draw art-group data (-> self enemy-info victory-anim)))))
(ja-channel-push! 1 (seconds 0.1))
)
)
(let ((f30-2 (rnd-float-range self 0.9 1.1)))
(ja-no-eval :group! (-> self draw art-group data (-> self enemy-info victory-anim))
:num! (seek! max f30-2)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-2))
)
)
)
)
#f
)
)
(defmethod enemy-method-77 ((this fodder) (arg0 enemy-knocked-info))
(case (-> this incoming knocked-type)
(((knocked-type knocked-type-6))
(let* ((a2-0 (ash 1 (-> *fodder-global-info* prev-blue-hit)))
(v1-3 (rnd-bit this 3 a2-0))
(s5-1 (-> this draw art-group data (-> *fodder-global-info* blue-hit-anim v1-3 anim-index)))
)
(set! (-> *fodder-global-info* prev-blue-hit) v1-3)
(let ((v1-6 (if (> (-> this skel active-channels) 0)
(-> this skel root-channel 0 frame-group)
)
)
)
(if (and v1-6 (= v1-6 (-> this draw art-group data 17)))
(ja-channel-push! 1 (seconds 0.17))
(ja-channel-push! 1 (seconds 0.02))
)
)
(let ((a0-18 (-> this skel root-channel 0)))
(set! (-> a0-18 frame-group) (the-as art-joint-anim s5-1))
(set! (-> a0-18 param 0) (the float (+ (-> (the-as art-joint-anim s5-1) frames num-frames) -1)))
(set! (-> a0-18 param 1) 1.0)
(set! (-> a0-18 frame-num) 0.0)
(joint-control-channel-group! a0-18 (the-as art-joint-anim s5-1) num-func-seek!)
)
)
)
(else
(let ((s4-0 (-> this draw art-group data 16)))
(ja-channel-push! 1 (seconds 0.17))
(let ((a0-20 (-> this skel root-channel 0)))
(set! (-> a0-20 frame-group) (the-as art-joint-anim s4-0))
(set! (-> a0-20 param 0) (the float (+ (-> (the-as art-joint-anim s4-0) frames num-frames) -1)))
(set! (-> a0-20 param 1) (-> arg0 anim-speed))
(set! (-> a0-20 frame-num) 0.0)
(joint-control-channel-group! a0-20 (the-as art-joint-anim s4-0) num-func-seek!)
)
)
)
)
#t
)
(defmethod enemy-method-78 ((this fodder) (arg0 enemy-knocked-info))
(case (-> this incoming knocked-type)
(((knocked-type knocked-type-6))
#f
)
(else
(let ((v1-5 (-> this draw art-group data (-> this enemy-info knocked-land-anim)))
(a0-3 (-> this skel root-channel 0))
)
(set! (-> a0-3 frame-group) (the-as art-joint-anim v1-5))
(set! (-> a0-3 param 0) (the float (+ (-> (the-as art-joint-anim v1-5) 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 v1-5) num-func-seek!)
)
#t
)
)
)
(defmethod fodder-method-181 ((this fodder) (arg0 symbol))
(let ((v1-3 (-> (the-as collide-shape-prim-group (-> this root root-prim)) child 1)))
(cond
(arg0
(set! (-> v1-3 prim-core collide-as) (collide-spec enemy))
(set! (-> v1-3 prim-core collide-with) (collide-spec jak bot player-list))
)
(else
(set! (-> v1-3 prim-core collide-as) (collide-spec))
(set! (-> v1-3 prim-core collide-with) (collide-spec))
0
)
)
)
(none)
)
(defmethod coin-flip? ((this fodder))
"@returns The result of a 50/50 RNG roll"
#f
)
(defmethod init-enemy-collision! ((this fodder))
"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 4915.2 0.0 4915.2)
)
(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 0.0 2662.4)
)
(set! (-> s5-0 nav-radius) 4505.6)
(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 relocate ((this fodder) (offset int))
(if (nonzero? (-> this left-eye))
(&+! (-> this left-eye) offset)
)
(if (nonzero? (-> this right-eye))
(&+! (-> this right-eye) offset)
)
(call-parent-method this offset)
)
(defun fodder-setup-eye-control ((arg0 joint-mod))
(set-vector! (-> arg0 twist-max) 16384.0 16384.0 0.0 1.0)
(set! (-> arg0 twist-min-x) 16384.0)
(set! (-> arg0 twist-min-y) 16384.0)
(set! (-> arg0 twist-speed-x) 0.2)
(set! (-> arg0 twist-speed-y) 0.2)
(set! (-> arg0 up) (the-as uint 1))
(set! (-> arg0 nose) (the-as uint 2))
(set! (-> arg0 ear) (the-as uint 0))
(set! (-> arg0 max-dist) 102400.0)
(set! (-> arg0 ignore-angle) 30947.555)
)
(defmethod init-enemy! ((this fodder))
"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-fodder" (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 *fodder-nav-enemy-info*)
(when (zero? (-> this left-eye))
(set! (-> this left-eye) (new 'process 'joint-mod (joint-mod-mode flex-blend) this 23))
(fodder-setup-eye-control (-> this left-eye))
)
(when (zero? (-> this right-eye))
(set! (-> this right-eye) (new 'process 'joint-mod (joint-mod-mode flex-blend) this 24))
(fodder-setup-eye-control (-> this right-eye))
)
(let ((v1-16 (-> this neck)))
(set! (-> v1-16 up) (the-as uint 1))
(set! (-> v1-16 nose) (the-as uint 2))
(set! (-> v1-16 ear) (the-as uint 0))
(set-vector! (-> v1-16 twist-max) 10922.667 7281.778 0.0 1.0)
(set! (-> v1-16 ignore-angle) 18204.445)
)
(set! (-> this look-at-other) (the-as handle #f))
(set! (-> this look-at-other-time) 0)
(set! (-> this neck-away-from) #f)
(let ((v1-18 (-> this nav)))
(set! (-> v1-18 speed-scale) 1.0)
)
0
(set-gravity-length (-> this root dynam) 573440.0)
(fodder-method-181 this #f)
0
(none)
)
(defmethod enemy-method-99 ((this fodder) (arg0 process-focusable))
(focus-test? arg0 mech)
)