Files
jak-project/goal_src/jak2/levels/common/enemy/grunt.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

1564 lines
57 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: grunt.gc
;; name in dgo: grunt
;; dgos: GAME, COMMON
;; DECOMP BEGINS
(defskelgroup skel-grunt grunt grunt-lod0-jg -1
((grunt-lod0-mg (meters 20)) (grunt-lod1-mg (meters 40)) (grunt-lod2-mg (meters 999999)))
:bounds (static-spherem 0 0 0 5)
:shadow grunt-shadow-mg
:origin-joint-index 18
)
(deftype grunt-anim-info (structure)
((anim-index int32)
(travel-speed meters)
)
:pack-me
)
(deftype grunt-global-info (basic)
((prev-knocked-anim-index int32)
(prev-yellow-hit-anim-index int32)
(prev-blue-hit-anim-index int32)
(patrol-anim grunt-anim-info 4 :inline)
(charge-anim grunt-anim-info 3 :inline)
(attack-anim grunt-anim-info 2 :inline)
(knocked-anim grunt-anim-info 4 :inline)
(knocked-land-anim grunt-anim-info 4 :inline)
(yellow-hit-anim grunt-anim-info 4 :inline)
(blue-hit-anim grunt-anim-info 6 :inline)
)
)
(deftype grunt (nav-enemy)
((patrol-anim grunt-anim-info)
(charge-anim grunt-anim-info)
(attack-anim grunt-anim-info)
(knocked-anim grunt-anim-info)
(yellow-hit-anim grunt-anim-info)
(blue-hit-anim grunt-anim-info)
(intro-path path-control)
(use-charge-anim-index int8)
(knocked-anim-index int8)
(jumping-ambush-path-pt int8)
(grunt-flags uint8)
(unknown-byte-n1k2n3 int8 :offset 636)
(unknown-byte-m2j342 int8 :offset 637)
(unknown-byte-1ji2n3 int8 :offset 638)
(unknown-byte-n123n uint8 :offset 639)
(state-timeout2 uint64)
(next-warn-time time-frame)
(dest vector :inline)
(minimap connection-minimap :offset 688)
)
(:state-methods
attack
falling-ambush
jumping-ambush
jumping-ambush-cont
wait-for-focus
spin-attack
)
(:methods
(grunt-method-184 (_type_ float) process-focusable)
(get-enemy-info (_type_) nav-enemy-info)
)
)
(define *grunt-global-info* (new 'static 'grunt-global-info
:patrol-anim (new 'static 'inline-array grunt-anim-info 4
(new 'static 'grunt-anim-info :anim-index 11 :travel-speed (meters 4))
(new 'static 'grunt-anim-info :anim-index 12 :travel-speed (meters 7))
(new 'static 'grunt-anim-info :anim-index 14 :travel-speed (meters 7))
(new 'static 'grunt-anim-info :anim-index 15 :travel-speed (meters 7))
)
:charge-anim (new 'static 'inline-array grunt-anim-info 3
(new 'static 'grunt-anim-info :anim-index 14 :travel-speed (meters 7))
(new 'static 'grunt-anim-info :anim-index 15 :travel-speed (meters 7))
(new 'static 'grunt-anim-info :anim-index 16 :travel-speed (meters 7))
)
:attack-anim (new 'static 'inline-array grunt-anim-info 2
(new 'static 'grunt-anim-info :anim-index 17 :travel-speed (meters 12))
(new 'static 'grunt-anim-info :anim-index 18 :travel-speed (meters 12))
)
:knocked-anim (new 'static 'inline-array grunt-anim-info 4
(new 'static 'grunt-anim-info :anim-index 22)
(new 'static 'grunt-anim-info :anim-index 24)
(new 'static 'grunt-anim-info :anim-index 26)
(new 'static 'grunt-anim-info :anim-index 28)
)
:knocked-land-anim (new 'static 'inline-array grunt-anim-info 4
(new 'static 'grunt-anim-info :anim-index 23)
(new 'static 'grunt-anim-info :anim-index 25)
(new 'static 'grunt-anim-info :anim-index 27)
(new 'static 'grunt-anim-info :anim-index 29)
)
:yellow-hit-anim (new 'static 'inline-array grunt-anim-info 4
(new 'static 'grunt-anim-info :anim-index 34)
(new 'static 'grunt-anim-info :anim-index 35)
(new 'static 'grunt-anim-info :anim-index 36)
(new 'static 'grunt-anim-info :anim-index 37)
)
:blue-hit-anim (new 'static 'inline-array grunt-anim-info 6
(new 'static 'grunt-anim-info :anim-index 38)
(new 'static 'grunt-anim-info :anim-index 39)
(new 'static 'grunt-anim-info :anim-index 40)
(new 'static 'grunt-anim-info :anim-index 41)
(new 'static 'grunt-anim-info :anim-index 42)
(new 'static 'grunt-anim-info :anim-index 43)
)
)
)
(define *grunt-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 36
(new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x5 :param0 #x1 :param1 #x3)
(new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x6 :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x7 :param0 #x1e :param1 #x69)
(new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x3c)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x5 :param0 #x1 :param1 #x3)
(new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x6 :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x7 :param0 #x1e :param1 #x69)
(new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x8 :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x9 :param0 #x1e :param1 #x69)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #xa :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x5 :param0 #x1 :param1 #x3)
(new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x8 :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x9 :param0 #x1e :param1 #x69)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #xa :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x5 :param0 #x1 :param1 #x3)
(new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x6 :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x7 :param0 #x1e :param1 #x69)
(new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x8 :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x9 :param0 #x1e :param1 #x69)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #xa :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x5 :param0 #x1 :param1 #x3)
(new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x1e)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x1e :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame :command (ic-cmd push) :param0 #x3c)
(new 'static 'idle-control-frame :command (ic-cmd play) :anim #x5 :param0 #x1 :param1 #x1)
(new 'static 'idle-control-frame)
)
:idle-anim 5
:notice-anim 13
:hostile-anim -1
:hit-anim 34
:knocked-anim -1
:knocked-land-anim -1
:die-anim 19
:die-falling-anim 32
:victory-anim -1
:jump-wind-up-anim 45
:jump-in-air-anim 46
:jump-land-anim 47
:neck-joint 5
:look-at-joint 6
:bullseye-joint 18
:sound-hit (static-sound-name "grunt-hit")
:sound-die (static-sound-name "grunt-die")
:notice-distance (meters 40)
:notice-distance-delta (meters 10)
:proximity-notice-distance (meters 20)
: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 5)
:attack-shove-up (meters 3)
: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 6371.5557
: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 6
:gem-seg #x2
:gem-no-seg #x4
:gem-offset (new 'static 'sphere :y 614.4 :z -3276.8 :r 327680.0)
:callback-info #f
:use-momentum #t
:use-frustration #t
:use-stop-chase #t
:use-circling #t
:use-pacing #t
:walk-anim 11
:turn-anim -1
:run-anim 14
:taunt-anim 20
:run-travel-speed (meters 7)
:run-acceleration (meters 6)
:run-turning-acceleration (meters 50)
:walk-travel-speed (meters 4)
:walk-acceleration (meters 6)
:walk-turning-acceleration (meters 3)
:maximum-rotation-rate (degrees 360)
: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! (-> *grunt-nav-enemy-info* fact-defaults) *fact-info-enemy-defaults*)
(defmethod general-event-handler ((this grunt) (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
(('hit 'hit-knocked)
(logclear! (-> this mask) (process-mask actor-pause))
(logclear! (-> this focus-status) (focus-status dangerous))
(logclear! (-> this enemy-flags) (enemy-flag use-notice-distance))
(logior! (-> this enemy-flags) (enemy-flag alert))
(logior! (-> this focus-status) (focus-status hit))
(if (zero? (-> this hit-points))
(logior! (-> this focus-status) (focus-status dead))
)
(logclear! (-> this enemy-flags) (enemy-flag lock-focus))
(enemy-method-62 this)
(logior! (-> this enemy-flags) (enemy-flag lock-focus))
(process-contact-action arg0)
(send-event arg0 'get-attack-count 1)
(cond
((zero? (-> this hit-points))
(let ((s5-1 (-> this incoming knocked-type)))
(cond
((and (= s5-1 (knocked-type knocked-type-4))
(not (and (-> this next-state) (let ((v1-33 (-> this next-state name)))
(or (= v1-33 'knocked) (= v1-33 'jump) (= v1-33 'jump-land))
)
)
)
(zero? (rnd-int-count this 3))
(>= (vector-vector-distance-squared (-> this root trans) (target-pos 0)) (square 32768.0))
)
(kill-prefer-falling this)
)
((or (= s5-1 (knocked-type knocked-type-4)) (= s5-1 (knocked-type knocked-type-6)))
(set! (-> this incoming knocked-type) (knocked-type knocked-type-0))
(go (method-of-object this knocked))
)
(else
(go (method-of-object this knocked))
)
)
)
)
(else
(go (method-of-object this knocked))
)
)
#t
)
(else
((method-of-type nav-enemy general-event-handler) this arg0 arg1 arg2 arg3)
)
)
)
(defmethod go-ambush ((this grunt))
(cond
((logtest? (-> this fact enemy-options) (enemy-option user10))
(go (method-of-object this falling-ambush))
)
((logtest? (-> this fact enemy-options) (enemy-option user11))
(go (method-of-object this jumping-ambush))
)
(else
(format 0 "ERROR: ~A doesn't specify which ambush behavior to use.~%" (-> this name))
(go-hostile this)
)
)
)
(defstate falling-ambush (grunt)
:virtual #t
:event enemy-event-handler
: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 ((a0-4 (the-as target (as-type *target* process-focusable))))
(when a0-4
(let* ((gp-2 (-> self root))
(s3-0 (vector-normalize! (vector-! (new 'stack-no-clear 'vector) (get-trans a0-4 0) (-> gp-2 trans)) 1.0))
(f0-0 (deg-diff (quaternion-y-angle (-> gp-2 quat)) (vector-y-angle s3-0)))
)
(quaternion-rotate-y! (-> gp-2 quat) (-> gp-2 quat) f0-0)
)
)
)
(logclear! (-> self draw status) (draw-control-status no-draw))
(let* ((v1-17 *game-info*)
(a0-15 (+ (-> v1-17 attack-id) 1))
)
(set! (-> v1-17 attack-id) a0-15)
(set! (-> self attack-id) a0-15)
)
(let ((v1-19 (-> self root root-prim)))
(set! (-> v1-19 prim-core collide-as) (collide-spec))
(set! (-> v1-19 prim-core collide-with) (collide-spec))
)
0
)
: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))
)
)
:code (behavior ()
(suspend-for (seconds 0.2)
)
(let ((v1-6 (-> self root root-prim)))
(set! (-> v1-6 prim-core collide-as) (-> self root backup-collide-as))
(set! (-> v1-6 prim-core collide-with) (-> self root backup-collide-with))
)
(sound-play "grunt-notice")
(ja-channel-push! 1 0)
(ja-no-eval :group! (-> self draw art-group data (-> self enemy-info notice-anim))
:num! (seek! max 1.8)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max 1.8))
)
(until (logtest? (-> self root status) (collide-status on-ground touch-surface touch-wall))
(suspend)
)
(go-virtual hostile)
)
:post nav-enemy-falling-post
)
;; WARN: Return type mismatch object vs none.
(defmethod enemy-method-93 ((this grunt))
(case (-> this jump-why)
((2)
(go (method-of-object this jumping-ambush-cont))
)
(else
((method-of-type nav-enemy enemy-method-93) this)
)
)
(none)
)
(defstate jumping-ambush (grunt)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
((-> (method-of-type nav-enemy ambush) enter))
(when (zero? (-> self intro-path))
(format 0 "ERROR: ~A has no intro path, skipping jumping-ambush~%" (-> self name))
(go-virtual notice)
)
(get-point-in-path! (-> self intro-path) (-> self root trans) 0.0 'interp)
)
:code (behavior ()
(set! (-> self unknown-byte-1ji2n3) 1)
(until #f
(let ((gp-0 (new 'stack-no-clear 'vector)))
(get-point-in-path! (-> self intro-path) gp-0 1.0 'interp)
(set! (-> self enemy-flags)
(the-as enemy-flag (logclear (-> self enemy-flags) (enemy-flag jump-check-blocked)))
)
(let ((a1-1 (new 'stack-no-clear 'event-message-block)))
(let ((v1-5 (process->ppointer self)))
(set! (-> a1-1 from) v1-5)
)
(set! (-> a1-1 num-params) 2)
(set! (-> a1-1 message) 'jump)
(set! (-> a1-1 param 0) (the-as uint 2))
(set! (-> a1-1 param 1) (the-as uint gp-0))
(send-event-function self a1-1)
)
)
(suspend)
)
#f
)
)
(defstate jumping-ambush-cont (grunt)
:virtual #t
:event enemy-event-handler
:code (behavior ()
(let ((a0-0 (-> self intro-path))
(v1-1 (+ (-> self unknown-byte-1ji2n3) 1))
)
(if (< v1-1 (-> a0-0 curve num-cverts))
(set! (-> self unknown-byte-1ji2n3) v1-1)
(react-to-focus self)
)
)
(until #f
(let ((gp-0 (new 'stack-no-clear 'vector)))
(get-point-in-path! (-> self intro-path) gp-0 (the float (-> self unknown-byte-1ji2n3)) 'interp)
(set! (-> self enemy-flags)
(the-as enemy-flag (logclear (-> self enemy-flags) (enemy-flag jump-check-blocked)))
)
(let ((a1-1 (new 'stack-no-clear 'event-message-block)))
(let ((v1-9 (process->ppointer self)))
(set! (-> a1-1 from) v1-9)
)
(set! (-> a1-1 num-params) 2)
(set! (-> a1-1 message) 'jump)
(set! (-> a1-1 param 0) (the-as uint 2))
(set! (-> a1-1 param 1) (the-as uint gp-0))
(send-event-function self a1-1)
)
)
(suspend)
)
#f
)
)
(defstate active (grunt)
:virtual #t
:code (behavior ()
(let ((v1-2 (ja-group)))
(when (or (and v1-2 (or (= v1-2 grunt-charge0-ja) (= v1-2 grunt-charge1-ja) (= v1-2 grunt-charge2-ja)))
(let ((v1-8 (ja-group)))
(and v1-8
(or (= v1-8 grunt-patrol0-ja) (= v1-8 grunt-patrol1-ja) (= v1-8 grunt-charge0-ja) (= v1-8 grunt-charge1-ja))
)
)
)
(ja-no-eval :num! (seek!))
(while (not (ja-done? 0))
(suspend)
(ja-eval)
)
)
)
(let ((f30-0 (rnd-float-range self 0.9 1.1)))
(until #f
(set! (-> self patrol-anim) (-> *grunt-global-info* patrol-anim (rnd-int-count self 4)))
(let ((v1-28 (-> self nav)))
(set! (-> v1-28 target-speed) (-> self patrol-anim travel-speed))
)
0
(let ((gp-0 (-> self draw art-group data (-> self patrol-anim anim-index)))
(s5-0 (rnd-int-range self 1 8))
)
(let ((v1-37 (ja-group)))
(if (not (and v1-37 (= v1-37 gp-0)))
(ja-channel-push! 1 (seconds 0.2))
)
)
(dotimes (s4-0 s5-0)
(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 (nonzero? (-> self patrol-anim anim-index))
(ja-no-eval :num! (loop!))
(ja-channel-push! 1 (seconds 0.2))
(set! (-> self patrol-anim) (the-as grunt-anim-info (-> *grunt-global-info* patrol-anim)))
(let ((v1-67 (-> self nav)))
(set! (-> v1-67 target-speed) (-> self patrol-anim travel-speed))
)
0
(let ((gp-1 (-> self draw art-group data (-> self patrol-anim anim-index)))
(s5-1 (rnd-int-range self 2 5))
)
(ja-no-eval :group! gp-1 :num! (seek! max f30-0) :frame-num 0.0)
(until (ja-done? 0)
(ja-blend-eval)
(suspend)
(ja :num! (seek! max f30-0))
)
(dotimes (s4-1 s5-1)
(ja-no-eval :group! gp-1 :num! (seek! max f30-0) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
)
)
)
(when (zero? (rnd-int-count self 3))
(let ((v1-107 self))
(set! (-> v1-107 enemy-flags)
(the-as enemy-flag (logclear (-> v1-107 enemy-flags) (enemy-flag enemy-flag36)))
)
(set! (-> v1-107 nav callback-info) *nav-enemy-null-callback-info*)
)
0
(nav-enemy-method-167 self)
(ja-channel-push! 1 (seconds 0.3))
(ja-no-eval :group! (-> self draw art-group data (-> self enemy-info idle-anim))
:num! (seek! max f30-0)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
(until (not (rnd-go-idle? self 0.2))
(ja-no-eval :group! (-> self draw art-group data (-> self enemy-info idle-anim))
:num! (seek! max f30-0)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
)
(let ((v1-171 self))
(if (not (logtest? (enemy-flag enemy-flag36) (-> v1-171 enemy-flags)))
(set! (-> v1-171 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag38) (-> v1-171 enemy-flags))))
)
(set! (-> v1-171 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag36) (-> v1-171 enemy-flags))))
(set! (-> v1-171 nav callback-info) (-> v1-171 enemy-info callback-info))
)
0
)
)
)
#f
)
)
(defmethod grunt-method-184 ((this grunt) (arg0 float))
(local-vars (v1-5 float))
(rlet ((acc :class vf)
(vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
)
(init-vf0-vector)
(let ((gp-0 (get-enemy-target this)))
(when gp-0
(let ((v1-3 (get-trans gp-0 0))
(s4-0 (new 'stack-no-clear 'vector))
)
(vector-! s4-0 v1-3 (-> this root trans))
(.lvf vf1 (&-> s4-0 quad))
(.add.w.vf.x vf2 vf0 vf0)
(.mul.vf vf1 vf1 vf1)
(.mul.x.vf.x acc vf2 vf1)
(.add.mul.y.vf.x acc vf2 vf1 acc)
(.add.mul.z.vf.x vf1 vf2 vf1 acc)
(.mov v1-5 vf1)
(let ((f30-0 v1-5)
(f28-0 (square arg0))
)
(when (or (>= (square 12288.0) f30-0) (>= f28-0 f30-0))
(let ((f26-0 (quaternion-y-angle (-> this root quat)))
(f0-7 (atan (-> s4-0 x) (-> s4-0 z)))
)
(cond
((and (< (square 1228.8) f30-0) (>= f28-0 f30-0) (>= 8192.0 (fabs (deg- f26-0 f0-7))))
(go (method-of-object this attack))
)
((< f30-0 (square 12288.0))
(go (method-of-object this spin-attack))
)
)
)
)
)
)
)
gp-0
)
)
)
(defstate hostile (grunt)
:virtual #t
:trans (behavior ()
(let ((t9-0 (-> (method-of-type nav-enemy hostile) trans)))
(if t9-0
(t9-0)
)
)
(let ((a0-1 (grunt-method-184 self 13312.0))
(gp-0 (current-time))
)
(when (and (>= gp-0 (-> self next-warn-time))
(not (logtest? (-> self draw status) (draw-control-status on-screen)))
)
(when (and a0-1 (>= (square 65536.0) (vector-vector-xz-distance-squared (get-trans a0-1 0) (-> self root trans))))
(sound-play "grunt-warn")
(set! (-> self next-warn-time) (+ gp-0 (rnd-int-range self 300 360)))
)
)
)
)
:code (behavior ()
(let ((v1-2 (ja-group)))
(when (and v1-2 (or (= v1-2 grunt-charge0-ja) (= v1-2 grunt-charge1-ja) (= v1-2 grunt-charge2-ja)))
(let ((v1-6 (-> self nav)))
(set! (-> v1-6 target-speed) (-> self charge-anim travel-speed))
)
0
(ja-no-eval :num! (seek!))
(while (not (ja-done? 0))
(suspend)
(ja-eval)
)
)
)
(let ((f30-0 (rnd-float-range self 0.9 1.1)))
(let ((v1-19 (-> self unknown-byte-n1k2n3)))
(cond
((>= v1-19 0)
(set! (-> self charge-anim) (-> *grunt-global-info* charge-anim v1-19))
(set! (-> self unknown-byte-n1k2n3) -1)
)
(else
(set! (-> self charge-anim) (-> *grunt-global-info* charge-anim (rnd-int-count self 3)))
)
)
)
(until #f
(grunt-method-184 self 22528.0)
(let ((gp-0 (-> self draw art-group data (-> self charge-anim anim-index))))
(let ((v1-37 (ja-group)))
(when (not (and v1-37 (= v1-37 gp-0)))
(ja-channel-push! 1 (seconds 0.1))
(let ((v1-41 (-> self nav)))
(set! (-> v1-41 target-speed) (-> self charge-anim travel-speed))
)
0
)
)
(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))
)
)
)
#f
)
:post nav-enemy-chase-post
)
(defstate attack (grunt)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(let ((v1-1 (-> self nav state)))
(set! (-> v1-1 speed) (-> self enemy-info run-travel-speed))
)
0
(logior! (-> self enemy-flags) (enemy-flag lock-focus))
(logior! (-> self focus-status) (focus-status dangerous))
(set! (-> self root penetrate-using) (penetrate generic-attack lunge))
(enemy-method-49 self)
(let* ((v1-10 *game-info*)
(v0-1 (+ (-> v1-10 attack-id) 1))
)
(set! (-> v1-10 attack-id) v0-1)
(set! (-> self attack-id) v0-1)
)
)
:exit (behavior ()
(logclear! (-> self enemy-flags) (enemy-flag lock-focus))
(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 ()
(enemy-method-49 self)
(when (logtest? (-> self enemy-flags) (enemy-flag victory))
(logclear! (-> self enemy-flags) (enemy-flag victory))
(sound-play "grunt-hit")
)
)
:code (behavior ()
(set! (-> self attack-anim) (-> *grunt-global-info* attack-anim (rnd-int-count self 2)))
(let ((v1-5 (-> self nav)))
(set! (-> v1-5 target-speed) (-> self attack-anim travel-speed))
)
0
(let ((v1-7 (-> self nav)))
(set! (-> v1-7 turning-acceleration) 49152.0)
)
0
(let ((gp-0 (-> self draw art-group data (-> self attack-anim anim-index)))
(f30-0 (rnd-float-range self 0.9 1.1))
)
(let ((v1-17 (ja-group)))
(if (not (and v1-17 (= v1-17 gp-0)))
(ja-channel-push! 1 (seconds 0.2))
)
)
(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))
)
)
(let ((v1-36 (-> self nav)))
(set! (-> v1-36 target-speed) (-> self charge-anim travel-speed))
)
0
(let ((v1-38 (-> self nav)))
(set! (-> v1-38 turning-acceleration) (-> self enemy-info run-turning-acceleration))
)
0
(let ((gp-1 (-> self draw art-group data (-> self charge-anim anim-index))))
(ja-channel-push! 1 (seconds 0.1))
(set! (-> self skel root-channel 0 frame-group) (the-as art-joint-anim gp-1))
)
(ja :num-func num-func-identity :frame-num (ja-aframe 3.0 0))
(let ((gp-3 (-> self focus aware)))
(if (or (not (get-enemy-target self)) (!= gp-3 3))
(go-stare self)
)
)
(let ((v1-57 0))
(let ((a0-22 (the-as object (-> *grunt-global-info* charge-anim)))
(a1-7 (-> self charge-anim))
)
(dotimes (a2-3 3)
(when (= a0-22 a1-7)
(set! v1-57 a2-3)
(goto cfg-21)
)
(set! a0-22 (&+ (the-as grunt-anim-info a0-22) 8))
)
)
(label cfg-21)
(set! (-> self unknown-byte-n1k2n3) v1-57)
)
(go-virtual hostile)
)
:post nav-enemy-chase-post
)
(defstate spin-attack (grunt)
:virtual #t
:event enemy-event-handler
:enter (behavior ()
(logior! (-> self enemy-flags) (enemy-flag lock-focus))
(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
(nav-enemy-method-167 self)
(let ((v1-7 self))
(set! (-> v1-7 enemy-flags) (the-as enemy-flag (logclear (-> v1-7 enemy-flags) (enemy-flag enemy-flag37))))
)
0
(let ((gp-0 (handle->process (-> self focus handle))))
(if (not gp-0)
(go-stare self)
)
(set! (-> self focus-pos quad) (-> (get-trans (the-as process-focusable gp-0) 0) quad))
)
(logior! (-> self focus-status) (focus-status dangerous))
(let* ((v1-21 *game-info*)
(v0-3 (+ (-> v1-21 attack-id) 1))
)
(set! (-> v1-21 attack-id) v0-3)
(set! (-> self attack-id) v0-3)
)
)
:exit (behavior ()
(logclear! (-> self enemy-flags) (enemy-flag lock-focus))
(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 ()
(when (logtest? (-> self enemy-flags) (enemy-flag victory))
(logclear! (-> self enemy-flags) (enemy-flag victory))
(sound-play "grunt-hit")
)
)
:code (behavior ()
(set! (-> self attack-anim) (-> *grunt-global-info* attack-anim (rnd-int-count self 2)))
(let ((gp-0 (-> self draw art-group data (-> self attack-anim anim-index)))
(f30-0 (rnd-float-range self 0.9 1.1))
)
(let ((v1-13 (ja-group)))
(if (not (and v1-13 (= v1-13 gp-0)))
(ja-channel-push! 1 (seconds 0.2))
)
)
(ja-no-eval :group! gp-0 :num! (seek! max f30-0) :frame-num 0.0)
(until (ja-done? 0)
(let ((a0-9 (handle->process (-> self focus handle))))
(if a0-9
(set! (-> self focus-pos quad) (-> (get-trans (the-as process-focusable a0-9) 0) quad))
)
)
(seek-to-point-toward-point! (-> self root) (-> self focus-pos) 546133.3 (seconds 0.1))
(suspend)
(ja :num! (seek! max f30-0))
)
)
(let ((gp-3 (-> self focus aware)))
(if (or (not (get-enemy-target self)) (!= gp-3 3))
(go-stare self)
)
)
(go-virtual hostile)
)
:post nav-enemy-simple-post
)
(defstate circling (grunt)
:virtual #t
:code (behavior ()
(let ((v1-2 (ja-group)))
(when (and v1-2 (or (= v1-2 grunt-charge0-ja) (= v1-2 grunt-charge1-ja) (= v1-2 grunt-charge2-ja)))
(let ((v1-6 (-> self nav)))
(set! (-> v1-6 target-speed) (-> self charge-anim travel-speed))
)
0
(ja-no-eval :num! (seek!))
(while (not (ja-done? 0))
(suspend)
(ja-eval)
)
)
)
(until #f
(set! (-> self charge-anim) (-> *grunt-global-info* charge-anim (rnd-int-count self 3)))
(let ((v1-22 self))
(if (not (logtest? (enemy-flag enemy-flag36) (-> v1-22 enemy-flags)))
(set! (-> v1-22 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag38) (-> v1-22 enemy-flags))))
)
(set! (-> v1-22 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag36) (-> v1-22 enemy-flags))))
(set! (-> v1-22 nav callback-info) (-> v1-22 enemy-info callback-info))
)
0
(let ((v1-25 self))
(set! (-> v1-25 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag37) (-> v1-25 enemy-flags))))
)
0
(let ((v1-27 (-> self nav)))
(set! (-> v1-27 target-speed) (-> self charge-anim travel-speed))
)
0
(let ((v1-29 (-> self nav)))
(set! (-> v1-29 acceleration) (-> self enemy-info run-acceleration))
)
0
(let ((v1-31 (-> self nav)))
(set! (-> v1-31 turning-acceleration) (-> self enemy-info run-turning-acceleration))
)
0
(let ((gp-0 (-> self draw art-group data (-> self charge-anim anim-index))))
(let ((v1-39 (ja-group)))
(if (not (and v1-39 (= v1-39 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-66 self))
(set! (-> v1-66 enemy-flags) (the-as enemy-flag (logclear (-> v1-66 enemy-flags) (enemy-flag enemy-flag36))))
(set! (-> v1-66 nav callback-info) *nav-enemy-null-callback-info*)
)
0
(nav-enemy-method-167 self)
(let ((v1-71 self))
(set! (-> v1-71 enemy-flags) (the-as enemy-flag (logclear (-> v1-71 enemy-flags) (enemy-flag enemy-flag37))))
)
0
(vector-reset! (-> self root transv))
(let ((v1-77 (ja-group)))
(if (not (and v1-77 (= v1-77 grunt-celebrate-start-ja)))
(ja-channel-push! 1 (seconds 0.1))
)
)
(let ((f30-2 (rnd-float-range self 0.9 1.1)))
(ja-no-eval :group! grunt-celebrate-start-ja :num! (seek! max f30-2) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-2))
)
(ja-no-eval :group! grunt-celebrate-finish-ja :num! (seek! max f30-2) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-2))
)
)
)
)
#f
)
)
(defstate pacing (grunt)
:virtual #t
:code (behavior ()
(let ((v1-2 (ja-group)))
(when (and v1-2 (or (= v1-2 grunt-charge0-ja) (= v1-2 grunt-charge1-ja) (= v1-2 grunt-charge2-ja)))
(let ((v1-6 (-> self nav)))
(set! (-> v1-6 target-speed) (-> self charge-anim travel-speed))
)
0
(ja-no-eval :num! (seek!))
(while (not (ja-done? 0))
(suspend)
(ja-eval)
)
)
)
(set! (-> self patrol-anim) (-> *grunt-global-info* patrol-anim (rnd-int-count self 4)))
(let ((f30-0 (rnd-float-range self 0.9 1.1))
(gp-0 (-> self draw art-group data (-> self patrol-anim anim-index)))
)
(let ((v1-28 self))
(if (not (logtest? (enemy-flag enemy-flag36) (-> v1-28 enemy-flags)))
(set! (-> v1-28 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag38) (-> v1-28 enemy-flags))))
)
(set! (-> v1-28 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag36) (-> v1-28 enemy-flags))))
(set! (-> v1-28 nav callback-info) (-> v1-28 enemy-info callback-info))
)
0
(let ((v1-31 self))
(set! (-> v1-31 enemy-flags) (the-as enemy-flag (logior (enemy-flag enemy-flag37) (-> v1-31 enemy-flags))))
)
0
(let ((v1-33 (-> self nav)))
(set! (-> v1-33 target-speed) (-> self patrol-anim travel-speed))
)
0
(let ((v1-35 (-> self nav)))
(set! (-> v1-35 acceleration) (-> self enemy-info walk-acceleration))
)
0
(let ((v1-37 (-> self nav)))
(set! (-> v1-37 turning-acceleration) (-> self enemy-info walk-turning-acceleration))
)
0
(let ((v1-41 (ja-group)))
(if (not (and v1-41 (= v1-41 gp-0)))
(ja-channel-push! 1 (seconds 0.2))
)
)
(until #f
(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))
)
)
)
#f
)
)
(defstate stop-chase (grunt)
:virtual #t
:code (behavior ()
(ja-no-eval :num! (seek!))
(while (not (ja-done? 0))
(suspend)
(ja-eval)
)
(set! (-> self patrol-anim) (-> *grunt-global-info* patrol-anim (rnd-int-count self 4)))
(let ((v1-14 (-> self nav)))
(set! (-> v1-14 target-speed) (-> self patrol-anim travel-speed))
)
0
(let ((f30-0 (rnd-float-range self 0.9 1.1))
(gp-0 (-> self draw art-group data (-> self patrol-anim anim-index)))
)
(let ((v1-24 (ja-group)))
(if (not (and v1-24 (= v1-24 gp-0)))
(ja-channel-push! 1 (seconds 0.2))
)
)
(until #f
(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))
)
)
)
#f
)
)
(defmethod enemy-method-77 ((this grunt) (arg0 enemy-knocked-info))
(local-vars (v1-72 int) (a2-3 int) (a2-5 int))
(case (-> this incoming knocked-type)
(((knocked-type knocked-type-4))
(let ((v1-2 (ash 1 (-> *grunt-global-info* prev-yellow-hit-anim-index)))
(a0-7 (if (> (-> this skel active-channels) 0)
(-> this skel root-channel 0 frame-group)
)
)
)
(if (and a0-7 (or (= a0-7 (-> this draw art-group data 16))
(= a0-7 (-> this draw art-group data 38))
(= a0-7 (-> this draw art-group data 39))
(= a0-7 (-> this draw art-group data 40))
)
)
(set! a2-3 (logior v1-2 4))
(set! a2-3 (logior v1-2 8))
)
)
(let ((s4-0 (rnd-bit this 4 a2-3)))
(set! (-> *grunt-global-info* prev-yellow-hit-anim-index) s4-0)
(set! (-> this yellow-hit-anim) (-> *grunt-global-info* yellow-hit-anim s4-0))
(let ((v1-11 (rnd-int-count this 3)))
(if (= s4-0 3)
(set! v1-11 2)
)
(set! (-> this unknown-byte-n1k2n3) v1-11)
)
)
(let ((s4-1 (-> this draw art-group data (-> this yellow-hit-anim anim-index))))
(ja-channel-push! 1 0)
(let ((a0-19 (-> this skel root-channel 0)))
(set! (-> a0-19 frame-group) (the-as art-joint-anim s4-1))
(set! (-> a0-19 param 0) (the float (+ (-> (the-as art-joint-anim s4-1) frames num-frames) -1)))
(set! (-> a0-19 param 1) (-> arg0 anim-speed))
(set! (-> a0-19 frame-num) 0.0)
(joint-control-channel-group! a0-19 (the-as art-joint-anim s4-1) num-func-seek!)
)
)
#t
)
(((knocked-type knocked-type-6))
(let* ((v1-24 (if (> (-> this skel active-channels) 0)
(-> this skel root-channel 0 frame-group)
)
)
(s4-2 (and v1-24 (or (= v1-24 (-> this draw art-group data 16))
(= v1-24 (-> this draw art-group data 38))
(= v1-24 (-> this draw art-group data 39))
(= v1-24 (-> this draw art-group data 40))
)
)
)
)
(if (>= (-> this incoming blue-juggle-count) (the-as uint 2))
(logior! (-> this unknown-byte-n123n) 2)
)
(cond
((and (not s4-2) (logtest? (-> this unknown-byte-n123n) 2))
(set! s4-2 #t)
(ja-channel-push! 1 (seconds 0.17))
)
(else
(let ((v1-36 (if (> (-> this skel active-channels) 0)
(-> this skel root-channel 0 frame-group)
)
)
)
(if (and v1-36 (= v1-36 (-> this draw art-group data 44)))
(ja-channel-push! 1 (seconds 0.17))
(ja-channel-push! 1 (seconds 0.02))
)
)
)
)
(let ((v1-42 (ash 1 (-> *grunt-global-info* prev-blue-hit-anim-index))))
(if s4-2
(set! a2-5 (logior v1-42 56))
(set! a2-5 (logior v1-42 7))
)
)
(let ((v1-46 (rnd-bit this 6 a2-5)))
(set! (-> *grunt-global-info* prev-blue-hit-anim-index) v1-46)
(set! (-> this blue-hit-anim) (-> *grunt-global-info* blue-hit-anim v1-46))
)
(let ((a2-6 0))
(when (not (logtest? (-> this unknown-byte-n123n) 2))
(if s4-2
(set! a2-6 (logior a2-6 3))
(set! a2-6 (logior a2-6 4))
)
)
(set! (-> this unknown-byte-n1k2n3) (rnd-bit this 3 a2-6))
)
)
(let ((a1-26 (-> this draw art-group data (-> this blue-hit-anim anim-index)))
(a0-51 (-> this skel root-channel 0))
)
(set! (-> a0-51 frame-group) (the-as art-joint-anim a1-26))
(set! (-> a0-51 param 0) (the float (+ (-> (the-as art-joint-anim a1-26) frames num-frames) -1)))
(set! (-> a0-51 param 1) (-> arg0 anim-speed))
(set! (-> a0-51 frame-num) 0.0)
(joint-control-channel-group! a0-51 (the-as art-joint-anim a1-26) num-func-seek!)
)
#t
)
(else
0
(cond
((or (= (-> this incoming knocked-type) (knocked-type knocked-type-2))
(= (-> this incoming knocked-type) (knocked-type knocked-type-3))
)
(set! v1-72 3)
)
(else
(let ((s4-3 (ash 1 (-> *grunt-global-info* prev-knocked-anim-index))))
(let ((s3-0 (-> this root)))
(if (>= 16384.0 (fabs (deg- (quaternion-y-angle (-> s3-0 quat)) (atan (-> s3-0 transv x) (-> s3-0 transv z)))))
(set! s4-3 (logior s4-3 4))
)
)
(set! v1-72 (rnd-bit this 3 s4-3))
)
)
)
(set! (-> *grunt-global-info* prev-knocked-anim-index) v1-72)
(set! (-> this unknown-byte-m2j342) v1-72)
(set! (-> this knocked-anim) (-> *grunt-global-info* knocked-anim v1-72))
(let ((s4-4 (-> this draw art-group data (-> this knocked-anim anim-index))))
(ja-channel-push! 1 0)
(let ((a0-68 (-> this skel root-channel 0)))
(set! (-> a0-68 frame-group) (the-as art-joint-anim s4-4))
(set! (-> a0-68 param 0) (the float (+ (-> (the-as art-joint-anim s4-4) frames num-frames) -1)))
(set! (-> a0-68 param 1) (-> arg0 anim-speed))
(set! (-> a0-68 frame-num) 0.0)
(joint-control-channel-group! a0-68 (the-as art-joint-anim s4-4) num-func-seek!)
)
)
#t
)
)
)
(defmethod enemy-method-78 ((this grunt) (arg0 enemy-knocked-info))
(cond
((= (-> this incoming knocked-type) (knocked-type knocked-type-6))
(when (or (logtest? (-> this unknown-byte-n123n) 2)
(let ((v1-7 (if (> (-> this skel active-channels) 0)
(-> this skel root-channel 0 frame-group)
)
)
)
(not (and v1-7 (or (= v1-7 (-> this draw art-group data 16))
(= v1-7 (-> this draw art-group data 38))
(= v1-7 (-> this draw art-group data 39))
(= v1-7 (-> this draw art-group data 40))
)
)
)
)
)
(let ((s4-0 (-> this draw art-group data 44)))
(ja-channel-push! 1 (seconds 0.17))
(let ((a0-16 (-> this skel root-channel 0)))
(set! (-> a0-16 frame-group) (the-as art-joint-anim s4-0))
(set! (-> a0-16 param 0) (the float (+ (-> (the-as art-joint-anim s4-0) frames num-frames) -1)))
(set! (-> a0-16 param 1) (-> arg0 anim-speed))
(set! (-> a0-16 frame-num) 0.0)
(joint-control-channel-group! a0-16 (the-as art-joint-anim s4-0) num-func-seek!)
)
)
(logand! (-> this unknown-byte-n123n) -3)
#t
)
)
((!= (-> this incoming knocked-type) (knocked-type knocked-type-4))
(let ((a1-6 (-> this
draw
art-group
data
(-> *grunt-global-info* knocked-land-anim (-> this unknown-byte-m2j342) anim-index)
)
)
(a0-23 (-> this skel root-channel 0))
)
(set! (-> a0-23 frame-group) (the-as art-joint-anim a1-6))
(set! (-> a0-23 param 0) (the float (+ (-> (the-as art-joint-anim a1-6) frames num-frames) -1)))
(set! (-> a0-23 param 1) (-> arg0 anim-speed))
(set! (-> a0-23 frame-num) 0.0)
(joint-control-channel-group! a0-23 (the-as art-joint-anim a1-6) num-func-seek!)
)
#t
)
)
)
(defstate wait-for-focus (grunt)
:virtual #t
:event enemy-event-handler
:enter (-> (method-of-type nav-enemy idle) enter)
:trans (behavior ()
(let ((s5-0 (handle->process (-> self focus handle))))
(when s5-0
(let ((gp-0 (get-trans (the-as process-focusable s5-0) 0)))
(when (and (or (not (logtest? (-> self enemy-flags) (enemy-flag use-notice-distance)))
(>= 163840.0 (vector-vector-distance (-> self root trans) gp-0))
)
(or (not (logtest? (-> self fact enemy-options) (enemy-option user8)))
(and (not (focus-test? (the-as process-focusable s5-0) in-air))
(>= 4096.0 (fabs (- (-> gp-0 y) (-> self root trans y))))
)
)
)
(cond
((and (logtest? (-> self fact enemy-options) (enemy-option user9))
(logtest? (-> self enemy-flags) (enemy-flag use-notice-distance))
)
(let ((s5-1 (new 'stack-no-clear 'vector)))
(vector-! s5-1 gp-0 (-> self root trans))
(let ((f0-2 32768.0)
(v1-26 s5-1)
)
(if (or (>= f0-2 (sqrtf (+ (* (-> v1-26 x) (-> v1-26 x)) (* (-> v1-26 z) (-> v1-26 z)))))
(>= 20024.889 (fabs (deg- (y-angle (-> self root)) (atan (-> s5-1 x) (-> s5-1 z)))))
)
(go-virtual notice)
)
)
)
)
(else
(go-virtual notice)
)
)
)
)
)
)
)
:code (-> (method-of-type nav-enemy idle) code)
:post (-> (method-of-type nav-enemy idle) post)
)
(defmethod dying ((this grunt))
"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)
)
;; WARN: Return type mismatch nav-enemy vs grunt.
(defmethod relocate ((this grunt) (offset int))
(if (nonzero? (-> this intro-path))
(&+! (-> this intro-path) offset)
)
(the-as grunt ((method-of-type nav-enemy relocate) this offset))
)
(defmethod init-enemy-collision! ((this grunt))
"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 7) 0)))
(set! (-> s5-0 total-prims) (the-as uint 8))
(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 can-ride deadly no-standon))
(set-vector! (-> s4-0 local-sphere) 0.0 6144.0 0.0 17408.0)
(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 backgnd jak bot crate obstacle hit-by-others-list player-list)
)
(set! (-> v1-13 prim-core action) (collide-action solid can-ride deadly no-standon))
(set-vector! (-> v1-13 local-sphere) 0.0 4915.2 0.0 4915.2)
)
(let ((v1-15 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
(set! (-> v1-15 prim-core collide-with) (collide-spec backgnd crate obstacle hit-by-others-list))
(set! (-> v1-15 prim-core action) (collide-action solid))
(set-vector! (-> v1-15 local-sphere) 0.0 9830.4 0.0 4915.2)
)
(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 prim-core action) (collide-action semi-solid deadly))
(set! (-> v1-17 transform-index) 4)
(set-vector! (-> v1-17 local-sphere) 0.0 0.0 0.0 4915.2)
)
(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 semi-solid deadly))
(set! (-> v1-19 transform-index) 18)
(set-vector! (-> v1-19 local-sphere) 0.0 0.0 0.0 2252.8)
)
(let ((v1-21 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
(set! (-> v1-21 prim-core collide-as) (collide-spec enemy))
(set! (-> v1-21 prim-core collide-with) (collide-spec jak bot player-list))
(set! (-> v1-21 prim-core action) (collide-action deadly))
(set! (-> v1-21 transform-index) 16)
(set-vector! (-> v1-21 local-sphere) 0.0 0.0 0.0 2048.0)
)
(let ((v1-23 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
(set! (-> v1-23 prim-core collide-as) (collide-spec enemy))
(set! (-> v1-23 prim-core collide-with) (collide-spec jak bot player-list))
(set! (-> v1-23 prim-core action) (collide-action deadly))
(set! (-> v1-23 transform-index) 12)
(set-vector! (-> v1-23 local-sphere) 0.0 0.0 0.0 2048.0)
)
(let ((v1-25 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
(set! (-> v1-25 prim-core collide-as) (collide-spec enemy))
(set! (-> v1-25 prim-core collide-with) (collide-spec jak bot player-list))
(set! (-> v1-25 prim-core action) (collide-action semi-solid deadly))
(set! (-> v1-25 transform-index) 6)
(set-vector! (-> v1-25 local-sphere) 0.0 0.0 0.0 2048.0)
)
(set! (-> s5-0 nav-radius) 8192.0)
(let ((v1-27 (-> s5-0 root-prim)))
(set! (-> s5-0 backup-collide-as) (-> v1-27 prim-core collide-as))
(set! (-> s5-0 backup-collide-with) (-> v1-27 prim-core collide-with))
)
(set! (-> s5-0 max-iteration-count) (the-as uint 3))
(set! (-> this root) s5-0)
)
0
(none)
)
(defmethod get-enemy-info ((this grunt))
"@returns the [[nav-enemy-info]] associated with this type of grunt"
*grunt-nav-enemy-info*
)
(defmethod init-enemy! ((this grunt))
"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-grunt" (the-as (pointer uint32) #f)))
(the-as pair 0)
)
(init-enemy-behaviour-and-stats! this (get-enemy-info this))
(let ((v1-6 (-> this neck)))
(set! (-> v1-6 up) (the-as uint 1))
(set! (-> v1-6 nose) (the-as uint 2))
(set! (-> v1-6 ear) (the-as uint 0))
(set-vector! (-> v1-6 twist-max) 11832.889 11832.889 0.0 1.0)
(set! (-> v1-6 ignore-angle) 30947.555)
)
(let ((v1-8 (-> this nav)))
(set! (-> v1-8 speed-scale) 1.0)
)
0
(set-gravity-length (-> this root dynam) 573440.0)
(let ((s5-2 *grunt-global-info*))
(set! (-> this patrol-anim) (-> s5-2 patrol-anim (rnd-int-count this 4)))
(set! (-> this charge-anim) (-> s5-2 charge-anim (rnd-int-count this 3)))
(set! (-> this attack-anim) (-> s5-2 attack-anim (rnd-int-count this 2)))
)
(set! (-> this unknown-byte-n1k2n3) -1)
(if (zero? (rnd-int-count this 2))
(logior! (-> this unknown-byte-n123n) 1)
)
(if (zero? (rnd-int-count this 2))
(logior! (-> this unknown-byte-n123n) 4)
)
(set! (-> this intro-path) (new 'process 'path-control this 'intro 0.0 (the-as entity #f) #t))
(add-connection
*part-engine*
this
6
this
318
(new 'static 'vector :x 1433.6 :y 2785.28 :z -1761.28 :w 163840.0)
)
(add-connection
*part-engine*
this
6
this
318
(new 'static 'vector :x -1433.6 :y 2785.28 :z -1761.28 :w 163840.0)
)
(set! (-> this minimap) (add-icon! *minimap* this (the-as uint 70) (the-as int #f) (the-as vector #t) 0))
0
(none)
)
(defmethod go-idle ((this grunt))
(if (logtest? (-> this fact enemy-options) (enemy-option user9))
(go (method-of-object this wait-for-focus))
(go (method-of-object this idle))
)
0
(none)
)