jak-project/goal_src/jak2/levels/common/grunt.gc
Tyler Wilding e5d6ac1c41
d/jak2: second documentation PR and finish forest-scenes and palace-scenes (#2136)
Also fixes #2135

Co-authored-by: water <awaterford111445@gmail.com>
2023-01-21 20:26:51 -05:00

1610 lines
63 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 :offset-assert 0)
(travel-speed meters :offset-assert 4)
)
:pack-me
:method-count-assert 9
:size-assert #x8
:flag-assert #x900000008
)
(deftype grunt-global-info (basic)
((prev-knocked-anim-index int32 :offset-assert 4)
(prev-yellow-hit-anim-index int32 :offset-assert 8)
(prev-blue-hit-anim-index int32 :offset-assert 12)
(patrol-anim grunt-anim-info 4 :inline :offset-assert 16)
(charge-anim grunt-anim-info 3 :inline :offset-assert 48)
(attack-anim grunt-anim-info 2 :inline :offset-assert 72)
(knocked-anim grunt-anim-info 4 :inline :offset-assert 88)
(knocked-land-anim grunt-anim-info 4 :inline :offset-assert 120)
(yellow-hit-anim grunt-anim-info 4 :inline :offset-assert 152)
(blue-hit-anim grunt-anim-info 6 :inline :offset-assert 184)
)
:method-count-assert 9
:size-assert #xe8
:flag-assert #x9000000e8
)
(deftype grunt (nav-enemy)
((patrol-anim grunt-anim-info :offset-assert 604)
(charge-anim grunt-anim-info :offset-assert 608)
(attack-anim grunt-anim-info :offset-assert 612)
(knocked-anim grunt-anim-info :offset-assert 616)
(yellow-hit-anim grunt-anim-info :offset-assert 620)
(blue-hit-anim grunt-anim-info :offset-assert 624)
(intro-path path-control :offset-assert 628)
(use-charge-anim-index int8 :offset-assert 632)
(knocked-anim-index int8 :offset-assert 633)
(jumping-ambush-path-pt int8 :offset-assert 634)
(grunt-flags uint8 :offset-assert 635)
(unknown-byte-n1k2n3 int8 :offset 636)
(unknown-byte-m2j342 int8 :offset 637)
(unknown-byte-1ji2n3 int8 :offset 638)
(unknown-byte-n123n int8 :offset 639)
(state-timeout2 uint64 :offset-assert 640)
(next-warn-time time-frame :offset-assert 648)
(dest vector :inline :offset-assert 656)
(minimap connection-minimap :offset 688)
)
:heap-base #x240
:method-count-assert 186
:size-assert #x2b4
:flag-assert #xba024002b4
(:methods
(attack () _type_ :state 178)
(falling-ambush () _type_ :state 179)
(jumping-ambush () _type_ :state 180)
(jumping-ambush-cont () _type_ :state 181)
(wait-for-focus () _type_ :state 182)
(spin-attack () _type_ :state 183)
(grunt-method-184 (_type_ float) process-focusable 184)
(get-enemy-info (_type_) nav-enemy-info 185)
)
)
(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 #xffffffffffffffff
: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.0)
: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 grunt ((obj 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! (-> obj mask) (process-mask actor-pause))
(logclear! (-> obj focus-status) (focus-status dangerous))
(logclear! (-> obj enemy-flags) (enemy-flag enable-on-notice))
(logior! (-> obj enemy-flags) (enemy-flag chase-startup))
(logior! (-> obj focus-status) (focus-status hit))
(if (zero? (-> obj hit-points))
(logior! (-> obj focus-status) (focus-status dead))
)
(logclear! (-> obj enemy-flags) (enemy-flag actor-pause-backup))
(enemy-method-62 obj)
(set! (-> obj enemy-flags) (logior (enemy-flag actor-pause-backup) (-> obj enemy-flags)))
(process-contact-action arg0)
(send-event arg0 'get-attack-count 1)
(cond
((zero? (-> obj hit-points))
(let ((s5-1 (-> obj incoming knocked-type)))
(cond
((and (= s5-1 (knocked-type knocked-type-4))
(not (and (-> obj next-state) (let ((v1-33 (-> obj next-state name)))
(or (= v1-33 'knocked) (= v1-33 'jump) (= v1-33 'jump-land))
)
)
)
(zero? (get-rand-int obj 3))
(let ((f0-0 (vector-vector-distance-squared (-> obj root-override2 trans) (target-pos 0)))
(f1-0 32768.0)
)
(>= f0-0 (* f1-0 f1-0))
)
)
(kill-prefer-falling obj)
)
((or (= s5-1 (knocked-type knocked-type-4)) (= s5-1 (knocked-type knocked-type-6)))
(set! (-> obj incoming knocked-type) (knocked-type knocked-type-0))
(go (method-of-object obj knocked))
)
(else
(go (method-of-object obj knocked))
)
)
)
)
(else
(go (method-of-object obj knocked))
)
)
#t
)
(else
((method-of-type nav-enemy general-event-handler) obj arg0 arg1 arg2 arg3)
)
)
)
(defmethod go-ambush grunt ((obj grunt))
(cond
((logtest? (-> obj fact-info-override enemy-options) (enemy-option user10))
(go (method-of-object obj falling-ambush))
)
((logtest? (-> obj fact-info-override enemy-options) (enemy-option user11))
(go (method-of-object obj jumping-ambush))
)
(else
(format 0 "ERROR: ~A doesn't specify which ambush behavior to use.~%" (-> obj name))
(go-hostile obj)
)
)
(none)
)
(defstate falling-ambush (grunt)
:virtual #t
:event (the-as (function process int symbol event-message-block object :behavior grunt) enemy-event-handler)
:enter (behavior ()
(when (logtest? (-> self enemy-flags) (enemy-flag auto-reset-penetrate))
(logclear! (-> self enemy-flags) (enemy-flag auto-reset-penetrate))
(let ((gp-0 (-> self on-notice)))
(if gp-0
(eval!
(new 'stack 'script-context (the-as basic (process->ppointer self)) self (-> self root-override2 trans))
(the-as pair gp-0)
)
)
)
)
(let* ((gp-1 *target*)
(a0-4 (if (type? gp-1 process-focusable)
gp-1
)
)
)
(when a0-4
(let* ((gp-2 (-> self root-override2))
(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-override2 root-prim)))
(set! (-> v1-19 prim-core collide-as) (collide-spec))
(set! (-> v1-19 prim-core collide-with) (collide-spec))
)
0
(none)
)
:exit (behavior ()
(let ((v1-1 (-> self root-override2 root-prim)))
(set! (-> v1-1 prim-core collide-as) (-> self root-override2 backup-collide-as))
(set! (-> v1-1 prim-core collide-with) (-> self root-override2 backup-collide-with))
)
(none)
)
:code (behavior ()
(let ((gp-0 (-> self clock frame-counter)))
(until (>= (- (-> self clock frame-counter) gp-0) (seconds 0.2))
(suspend)
)
)
(let ((v1-6 (-> self root-override2 root-prim)))
(set! (-> v1-6 prim-core collide-as) (-> self root-override2 backup-collide-as))
(set! (-> v1-6 prim-core collide-with) (-> self root-override2 backup-collide-with))
)
(sound-play "grunt-notice")
(ja-channel-push! 1 0)
(ja-no-eval :group! (-> self draw art-group data (-> self enemy-info-override notice-anim))
:num! (seek!
(the float
(+ (-> (the-as art-joint-anim (-> self draw art-group data (-> self enemy-info-override notice-anim)))
frames
num-frames
)
-1
)
)
1.8
)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max 1.8))
)
(until (logtest? (-> self root-override2 status) (collide-status on-ground touch-surface touch-wall))
(suspend)
)
(go-virtual hostile)
(none)
)
:post (the-as (function none :behavior grunt) nav-enemy-falling-post)
)
(defmethod enemy-method-93 grunt ((obj grunt))
(case (-> obj jump-why)
((2)
(go (method-of-object obj jumping-ambush-cont))
)
(else
((method-of-type nav-enemy enemy-method-93) obj)
)
)
(none)
)
(defstate jumping-ambush (grunt)
:virtual #t
:event (the-as (function process int symbol event-message-block object :behavior grunt) 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-override2 trans) 0.0 'interp)
(none)
)
: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 vulnerable))))
(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
(none)
)
)
(defstate jumping-ambush-cont (grunt)
:virtual #t
:event (the-as (function process int symbol event-message-block object :behavior grunt) 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 vulnerable))))
(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
(none)
)
)
(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 (get-rand-float-range self 0.9 1.1)))
(until #f
(set! (-> self patrol-anim) (-> *grunt-global-info* patrol-anim (get-rand-int 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 (get-rand-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! (the float (+ (-> (the-as art-joint-anim gp-0) frames num-frames) -1)) 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 (get-rand-int-range self 2 5))
)
(ja-no-eval :group! gp-1
:num! (seek! (the float (+ (-> (the-as art-joint-anim gp-1) frames num-frames) -1)) 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! (the float (+ (-> (the-as art-joint-anim gp-1) frames num-frames) -1)) f30-0)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
)
)
)
(when (zero? (get-rand-int 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-override idle-anim))
:num! (seek!
(the float
(+ (-> (the-as art-joint-anim (-> self draw art-group data (-> self enemy-info-override idle-anim)))
frames
num-frames
)
-1
)
)
f30-0
)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
(until (not (enemy-method-123 self 0.2))
(ja-no-eval :group! (-> self draw art-group data (-> self enemy-info-override idle-anim))
:num! (seek!
(the float
(+ (-> (the-as art-joint-anim (-> self draw art-group data (-> self enemy-info-override idle-anim)))
frames
num-frames
)
-1
)
)
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-override callback-info))
)
0
)
)
)
#f
(none)
)
)
(defmethod grunt-method-184 grunt ((obj 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 obj)))
(when gp-0
(let ((v1-3 (get-trans gp-0 0))
(s4-0 (new 'stack-no-clear 'vector))
)
(vector-! s4-0 v1-3 (-> obj root-override2 trans))
(.lvf vf1 (&-> s4-0 quad))
(.add.w.vf vf2 vf0 vf0 :mask #b1)
(.mul.vf vf1 vf1 vf1)
(.mul.x.vf acc vf2 vf1 :mask #b1)
(.add.mul.y.vf acc vf2 vf1 acc :mask #b1)
(.add.mul.z.vf vf1 vf2 vf1 acc :mask #b1)
(.mov v1-5 vf1)
(let* ((f30-0 v1-5)
(f0-0 arg0)
(f28-0 (* f0-0 f0-0))
(f0-2 12288.0)
)
(when (or (>= (* f0-2 f0-2) f30-0) (>= f28-0 f30-0))
(let ((f26-0 (quaternion-y-angle (-> obj root-override2 quat)))
(f0-7 (atan (-> s4-0 x) (-> s4-0 z)))
(f1-0 1228.8)
)
(cond
((and (< (* f1-0 f1-0) f30-0) (>= f28-0 f30-0) (>= 8192.0 (fabs (deg- f26-0 f0-7))))
(go (method-of-object obj attack))
)
((let ((f0-10 12288.0))
(< f30-0 (* f0-10 f0-10))
)
(go (method-of-object obj 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 (-> self clock frame-counter))
)
(when (and (>= gp-0 (-> self next-warn-time))
(zero? (logand (-> self draw status) (draw-control-status on-screen)))
)
(when (and a0-1
(let ((f0-0 65536.0))
(>= (* f0-0 f0-0) (vector-vector-xz-distance-squared (get-trans a0-1 0) (-> self root-override2 trans)))
)
)
(sound-play "grunt-warn")
(set! (-> self next-warn-time) (+ gp-0 (get-rand-int-range self 300 360)))
)
)
)
(none)
)
: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 (get-rand-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 (get-rand-int 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! (the float (+ (-> (the-as art-joint-anim gp-0) frames num-frames) -1)) f30-0)
:frame-num 0.0
)
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
)
)
#f
(none)
)
:post (the-as (function none :behavior grunt) nav-enemy-chase-post)
)
(defstate attack (grunt)
:virtual #t
:event (the-as (function process int symbol event-message-block object :behavior grunt) enemy-event-handler)
:enter (behavior ()
(let ((v1-1 (-> self nav state)))
(set! (-> v1-1 speed) (-> self enemy-info-override run-travel-speed))
)
0
(set! (-> self enemy-flags) (logior (enemy-flag actor-pause-backup) (-> self enemy-flags)))
(logior! (-> self focus-status) (focus-status dangerous))
(set! (-> self root-override2 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)
)
(none)
)
:exit (behavior ()
(logclear! (-> self enemy-flags) (enemy-flag actor-pause-backup))
(if (logtest? (-> self enemy-flags) (enemy-flag check-water))
(logior! (-> self focus-status) (focus-status dangerous))
(logclear! (-> self focus-status) (focus-status dangerous))
)
(none)
)
:trans (behavior ()
(enemy-method-49 self)
(when (logtest? (-> self enemy-flags) (enemy-flag look-at-focus))
(logclear! (-> self enemy-flags) (enemy-flag look-at-focus))
(sound-play "grunt-hit")
)
(none)
)
:code (behavior ()
(set! (-> self attack-anim) (-> *grunt-global-info* attack-anim (get-rand-int 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 (get-rand-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! (the float (+ (-> (the-as art-joint-anim gp-0) frames num-frames) -1)) 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-override 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)
(none)
)
:post (the-as (function none :behavior grunt) nav-enemy-chase-post)
)
(defstate spin-attack (grunt)
:virtual #t
:event (the-as (function process int symbol event-message-block object :behavior grunt) enemy-event-handler)
:enter (behavior ()
(set! (-> self enemy-flags) (logior (enemy-flag actor-pause-backup) (-> self enemy-flags)))
(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)
)
(none)
)
:exit (behavior ()
(logclear! (-> self enemy-flags) (enemy-flag actor-pause-backup))
(if (logtest? (-> self enemy-flags) (enemy-flag check-water))
(logior! (-> self focus-status) (focus-status dangerous))
(logclear! (-> self focus-status) (focus-status dangerous))
)
(none)
)
:trans (behavior ()
(when (logtest? (-> self enemy-flags) (enemy-flag look-at-focus))
(logclear! (-> self enemy-flags) (enemy-flag look-at-focus))
(sound-play "grunt-hit")
)
(none)
)
:code (behavior ()
(set! (-> self attack-anim) (-> *grunt-global-info* attack-anim (get-rand-int self 2)))
(let ((gp-0 (-> self draw art-group data (-> self attack-anim anim-index)))
(f30-0 (get-rand-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! (the float (+ (-> (the-as art-joint-anim gp-0) frames num-frames) -1)) 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-override2) (-> 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)
(none)
)
:post (the-as (function none :behavior grunt) 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 (get-rand-int 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-override 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-override run-acceleration))
)
0
(let ((v1-31 (-> self nav)))
(set! (-> v1-31 turning-acceleration) (-> self enemy-info-override 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 (get-rand-int self 8))
(f30-0 (get-rand-float-range self 0.9 1.1))
)
(while (nonzero? s5-0)
(+! s5-0 -1)
(ja-no-eval :group! gp-0
:num! (seek! (the float (+ (-> (the-as art-joint-anim gp-0) frames num-frames) -1)) 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-override2 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-override2 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 (get-rand-float-range self 0.9 1.1)))
(ja-no-eval :group! grunt-celebrate-start-ja
:num! (seek! (the float (+ (-> (the-as art-joint-anim grunt-celebrate-start-ja) frames num-frames) -1)) 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! (the float (+ (-> (the-as art-joint-anim grunt-celebrate-finish-ja) frames num-frames) -1)) f30-2)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-2))
)
)
)
)
#f
(none)
)
)
(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 (get-rand-int self 4)))
(let ((f30-0 (get-rand-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-override 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-override walk-acceleration))
)
0
(let ((v1-37 (-> self nav)))
(set! (-> v1-37 turning-acceleration) (-> self enemy-info-override 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! (the float (+ (-> (the-as art-joint-anim gp-0) frames num-frames) -1)) f30-0)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
)
)
#f
(none)
)
)
(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 (get-rand-int self 4)))
(let ((v1-14 (-> self nav)))
(set! (-> v1-14 target-speed) (-> self patrol-anim travel-speed))
)
0
(let ((f30-0 (get-rand-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! (the float (+ (-> (the-as art-joint-anim gp-0) frames num-frames) -1)) f30-0)
:frame-num 0.0
)
(until (ja-done? 0)
(suspend)
(ja :num! (seek! max f30-0))
)
)
)
#f
(none)
)
)
(defmethod enemy-method-77 grunt ((obj grunt) (arg0 (pointer float)))
(local-vars (v1-72 int) (a2-3 int) (a2-5 int))
(case (-> obj incoming knocked-type)
(((knocked-type knocked-type-4))
(let ((v1-2 (ash 1 (-> *grunt-global-info* prev-yellow-hit-anim-index)))
(a0-7 (if (> (-> obj skel active-channels) 0)
(-> obj skel root-channel 0 frame-group)
)
)
)
(if (and a0-7 (or (= a0-7 (-> obj draw art-group data 16))
(= a0-7 (-> obj draw art-group data 38))
(= a0-7 (-> obj draw art-group data 39))
(= a0-7 (-> obj draw art-group data 40))
)
)
(set! a2-3 (logior v1-2 4))
(set! a2-3 (logior v1-2 8))
)
)
(let ((s4-0 (enemy-method-120 obj 4 a2-3)))
(set! (-> *grunt-global-info* prev-yellow-hit-anim-index) s4-0)
(set! (-> obj yellow-hit-anim) (-> *grunt-global-info* yellow-hit-anim s4-0))
(let ((v1-11 (get-rand-int obj 3)))
(if (= s4-0 3)
(set! v1-11 2)
)
(set! (-> obj unknown-byte-n1k2n3) v1-11)
)
)
(let ((s4-1 (-> obj draw art-group data (-> obj yellow-hit-anim anim-index))))
(ja-channel-push! 1 0)
(let ((a0-19 (-> obj 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 0))
(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 (> (-> obj skel active-channels) 0)
(-> obj skel root-channel 0 frame-group)
)
)
(s4-2 (and v1-24 (or (= v1-24 (-> obj draw art-group data 16))
(= v1-24 (-> obj draw art-group data 38))
(= v1-24 (-> obj draw art-group data 39))
(= v1-24 (-> obj draw art-group data 40))
)
)
)
)
(if (>= (-> obj incoming blue-juggle-count) (the-as uint 2))
(set! (-> obj unknown-byte-n123n) (the-as int (logior (-> obj stack 511) 2)))
)
(cond
((and (not s4-2) (logtest? (-> obj stack 511) 2))
(set! s4-2 #t)
(ja-channel-push! 1 (seconds 0.17))
)
(else
(let ((v1-36 (if (> (-> obj skel active-channels) 0)
(-> obj skel root-channel 0 frame-group)
)
)
)
(if (and v1-36 (= v1-36 (-> obj 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 (enemy-method-120 obj 6 a2-5)))
(set! (-> *grunt-global-info* prev-blue-hit-anim-index) v1-46)
(set! (-> obj blue-hit-anim) (-> *grunt-global-info* blue-hit-anim v1-46))
)
(let ((a2-6 0))
(when (not (logtest? (-> obj stack 511) 2))
(if s4-2
(set! a2-6 (logior a2-6 3))
(set! a2-6 (logior a2-6 4))
)
)
(set! (-> obj unknown-byte-n1k2n3) (enemy-method-120 obj 3 a2-6))
)
)
(let ((a1-26 (-> obj draw art-group data (-> obj blue-hit-anim anim-index)))
(a0-51 (-> obj 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 0))
(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 (= (-> obj incoming knocked-type) (knocked-type knocked-type-2))
(= (-> obj 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 (-> obj root-override2)))
(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 (enemy-method-120 obj 3 s4-3))
)
)
)
(set! (-> *grunt-global-info* prev-knocked-anim-index) v1-72)
(set! (-> obj unknown-byte-m2j342) v1-72)
(set! (-> obj knocked-anim) (-> *grunt-global-info* knocked-anim v1-72))
(let ((s4-4 (-> obj draw art-group data (-> obj knocked-anim anim-index))))
(ja-channel-push! 1 0)
(let ((a0-68 (-> obj 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 0))
(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 grunt ((obj grunt) (arg0 (pointer float)))
(cond
((= (-> obj incoming knocked-type) (knocked-type knocked-type-6))
(when (or (logtest? (-> obj stack 511) 2) (let ((v1-7 (if (> (-> obj skel active-channels) 0)
(-> obj skel root-channel 0 frame-group)
)
)
)
(not (and v1-7 (or (= v1-7 (-> obj draw art-group data 16))
(= v1-7 (-> obj draw art-group data 38))
(= v1-7 (-> obj draw art-group data 39))
(= v1-7 (-> obj draw art-group data 40))
)
)
)
)
)
(let ((s4-0 (-> obj draw art-group data 44)))
(ja-channel-push! 1 (seconds 0.17))
(let ((a0-16 (-> obj 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 0))
(set! (-> a0-16 frame-num) 0.0)
(joint-control-channel-group! a0-16 (the-as art-joint-anim s4-0) num-func-seek!)
)
)
(set! (-> obj unknown-byte-n123n) (the-as int (logand -3 (-> obj stack 511))))
#t
)
)
((!= (-> obj incoming knocked-type) (knocked-type knocked-type-4))
(let ((a1-6 (-> obj
draw
art-group
data
(-> *grunt-global-info* knocked-land-anim (-> obj unknown-byte-m2j342) anim-index)
)
)
(a0-23 (-> obj 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 0))
(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 (the-as (function process int symbol event-message-block object :behavior grunt) 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 enable-on-notice)))
(>= 163840.0 (vector-vector-distance (-> self root-override2 trans) gp-0))
)
(or (not (logtest? (-> self fact-info-override enemy-options) (enemy-option user8)))
(and (not (logtest? (-> (the-as process-focusable s5-0) focus-status) (focus-status in-air)))
(>= 4096.0 (fabs (- (-> gp-0 y) (-> self root-override2 trans y))))
)
)
)
(cond
((and (logtest? (-> self fact-info-override enemy-options) (enemy-option user9))
(logtest? (-> self enemy-flags) (enemy-flag enable-on-notice))
)
(let ((s5-1 (new 'stack-no-clear 'vector)))
(vector-! s5-1 gp-0 (-> self root-override2 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-override2)) (atan (-> s5-1 x) (-> s5-1 z)))))
)
(go-virtual notice)
)
)
)
)
(else
(go-virtual notice)
)
)
)
)
)
)
(none)
)
:code (-> (method-of-type nav-enemy idle) code)
:post (-> (method-of-type nav-enemy idle) post)
)
(defmethod dispose! grunt ((obj grunt))
"Cleans-up the enemy and any associated resources. Potentially spawns skull gems"
(when (-> obj minimap)
(logior! (-> obj minimap flags) (minimap-flag fade-out))
(set! (-> obj minimap) #f)
)
((the-as (function nav-enemy none) (find-parent-method grunt 132)) obj)
(none)
)
;; WARN: Return type mismatch nav-enemy vs grunt.
(defmethod relocate grunt ((obj grunt) (arg0 int))
(if (nonzero? (-> obj intro-path))
(&+! (-> obj intro-path) arg0)
)
(the-as grunt ((method-of-type nav-enemy relocate) obj arg0))
)
(defmethod init-enemy-collision! grunt ((obj grunt))
"Initializes the [[collide-shape-moving]] and any ancillary tasks to make the enemy collide properly"
(let ((s5-0 (new 'process 'collide-shape-moving obj (collide-list-enum usually-hit-by-player))))
(set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> s5-0 reaction) 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! (-> obj root-override2) s5-0)
)
0
(none)
)
(defmethod get-enemy-info grunt ((obj grunt))
"@returns the [[nav-enemy-info]] associated with this type of grunt"
*grunt-nav-enemy-info*
)
(defmethod init-enemy! grunt ((obj grunt))
"Common method called to initialize the enemy, typically sets up default field values and calls ancillary helper methods"
(initialize-skeleton
obj
(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! obj (get-enemy-info obj))
(let ((v1-6 (-> obj 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 (-> obj nav)))
(set! (-> v1-8 speed-scale) 1.0)
)
0
(set-gravity-length (-> obj root-override2 dynam) 573440.0)
(let ((s5-2 *grunt-global-info*))
(set! (-> obj patrol-anim) (-> s5-2 patrol-anim (get-rand-int obj 4)))
(set! (-> obj charge-anim) (-> s5-2 charge-anim (get-rand-int obj 3)))
(set! (-> obj attack-anim) (-> s5-2 attack-anim (get-rand-int obj 2)))
)
(set! (-> obj unknown-byte-n1k2n3) -1)
(if (zero? (get-rand-int obj 2))
(set! (-> obj unknown-byte-n123n) (the-as int (logior (-> obj stack 511) 1)))
)
(if (zero? (get-rand-int obj 2))
(set! (-> obj unknown-byte-n123n) (the-as int (logior (-> obj stack 511) 4)))
)
(set! (-> obj intro-path) (new 'process 'path-control obj 'intro 0.0 (the-as entity #f) #t))
(add-connection
*part-engine*
obj
6
obj
318
(new 'static 'vector :x 1433.6 :y 2785.28 :z -1761.28 :w 163840.0)
)
(add-connection
*part-engine*
obj
6
obj
318
(new 'static 'vector :x -1433.6 :y 2785.28 :z -1761.28 :w 163840.0)
)
(set! (-> obj minimap) (add-icon! *minimap* obj (the-as uint 70) (the-as int #f) (the-as vector #t) 0))
0
(none)
)
(defmethod go-idle grunt ((obj grunt))
(if (logtest? (-> obj fact-info-override enemy-options) (enemy-option user9))
(go (method-of-object obj wait-for-focus))
(go (method-of-object obj idle))
)
0
(none)
)