jak-project/goal_src/levels/common/sharkey.gc
water111 be74613332
cleanup and bug fix (#1161)
* cleanup and bug fix

* crashing

* fix crash bug

* fix tests
2022-02-13 13:03:30 -05:00

870 lines
32 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: sharkey.gc
;; name in dgo: sharkey
;; dgos: GAME, COMMON, L1
;; DECOMP BEGINS
(defpartgroup group-sharkey-splash
:id 106
:duration 120
:linger-duration 780
:flags (use-local-clock)
:bounds (static-bspherem 0 -12 0 14)
:parts
((sp-item 124 :flags (is-3d) :period 900 :length 63)
(sp-item 125 :period 900 :length 15)
(sp-item 126 :flags (is-3d) :period 900 :length 15)
(sp-item 127 :flags (is-3d) :period 900 :length 15)
(sp-item 128 :period 900 :length 10 :binding 129)
(sp-item 129 :flags (start-dead) :period 900 :length 120)
(sp-item 129 :flags (start-dead) :period 900 :length 120)
(sp-item 129 :flags (start-dead) :period 900 :length 120)
(sp-item 129 :flags (start-dead) :period 900 :length 120)
(sp-item 129 :flags (start-dead) :period 900 :length 120)
(sp-item 129 :flags (start-dead) :period 900 :length 120)
(sp-item 129 :flags (start-dead) :period 900 :length 120)
(sp-item 129 :flags (start-dead) :period 900 :length 120)
(sp-item 129 :flags (start-dead) :period 900 :length 120)
(sp-item 129 :flags (start-dead) :period 900 :length 120)
(sp-item 129 :flags (start-dead) :period 900 :length 120)
)
)
(deftype sharkey (nav-enemy)
((dir vector :inline :offset-assert 400)
(spawn-point vector :inline :offset-assert 416)
(scale float :offset-assert 432)
(anim-speed float :offset-assert 436)
(y-max meters :offset-assert 440)
(y-min meters :offset-assert 444)
(attack-time float :offset-assert 448)
(player-water-time time-frame :offset-assert 456)
(player-in-water basic :offset-assert 464)
(last-y float :offset-assert 468)
(spawn-distance meters :offset-assert 472)
(chase-speed meters :offset-assert 476)
(y-speed meters :offset-assert 480)
(sound-id sound-id :offset-assert 484)
(enable-patrol basic :offset-assert 488)
)
:heap-base #x180
:method-count-assert 76
:size-assert #x1ec
:flag-assert #x4c018001ec
)
(defskelgroup *sharkey-sg* sharkey
0
2
((1 (meters 999999)))
:bounds (static-spherem 0 0 0 6)
:longest-edge (meters 0)
)
(defmethod dummy-44 sharkey ((obj sharkey) (arg0 process) (arg1 event-message-block))
(the-as object #t)
)
(defmethod dummy-43 sharkey ((obj sharkey) (arg0 process) (arg1 event-message-block))
(the-as object #t)
)
nav-enemy-default-event-handler
(defmethod run-logic? sharkey ((obj sharkey))
(or (zero? (logand (-> obj mask) (process-mask actor-pause)))
(or (>= (+ (-> *ACTOR-bank* pause-dist) (-> obj collide-info pause-adjust-distance))
(vector-vector-distance (-> obj collide-info trans) (math-camera-pos))
)
(and (nonzero? (-> obj skel)) (!= (-> obj skel root-channel 0) (-> obj skel channel)))
(and (nonzero? (-> obj draw)) (logtest? (-> obj draw status) (draw-status no-skeleton-update)))
)
)
)
(defmethod dummy-40 sharkey ((obj sharkey))
(dummy-11 (-> obj nav) (-> obj nav target-pos))
(let* ((f0-0 (vector-vector-xz-distance (-> obj collide-info trans) (-> obj nav target-pos)))
(f30-0 (/ (- (fmin (-> obj y-max) (-> obj nav target-pos y)) (-> obj collide-info trans y)) f0-0))
)
(set! (-> obj nav travel y) (* 4.0 (vector-length (-> obj nav travel)) f30-0))
)
0
(none)
)
(defmethod TODO-RENAME-37 sharkey ((obj sharkey))
(let ((s5-0 (new 'stack-no-clear 'vector)))
(when (< 8192.0 (vector-length (-> obj nav travel)))
(vector-normalize-copy! s5-0 (-> obj nav travel) 1.0)
(vector-deg-seek (-> obj dir) (-> obj dir) s5-0 (* 65536.0 (-> *display* seconds-per-frame)))
(vector-normalize! (-> obj dir) 1.0)
(forward-up->quaternion (-> obj collide-info quat) (-> obj dir) *up-vector*)
)
)
0
(none)
)
(defmethod dummy-41 sharkey ((obj sharkey))
(let* ((f0-1 (- (-> obj target-speed) (-> obj momentum-speed)))
(f1-3 (fmin (* (-> obj acceleration) (-> *display* seconds-per-frame)) (fabs f0-1)))
)
(if (< f0-1 0.0)
(set! (-> obj momentum-speed) (- (-> obj momentum-speed) f1-3))
(+! (-> obj momentum-speed) f1-3)
)
)
(let ((f0-9 (fmin
(* (-> obj speed-scale) (-> obj momentum-speed))
(* (vector-length (-> obj nav travel)) (-> *display* frames-per-second))
)
)
)
(vector-normalize-copy! (-> obj collide-info transv) (-> obj nav travel) f0-9)
)
0
(none)
)
(defmethod common-post sharkey ((obj sharkey))
(let ((f30-0 (-> obj water height))
(s5-0 (new 'stack-no-clear 'vector))
)
(let* ((f3-0 (- -36864.0 (-> obj collide-info trans y)))
(f0-2 (fmax 0.0 (fmin 1.0 (- 1.0 (* 0.00008138021 f3-0)))))
)
(set-vector! (-> obj draw color-mult) f0-2 f0-2 f0-2 1.0)
)
(dummy-10 (-> obj water))
(let ((f28-0 (-> obj collide-info trans y)))
(when (or (and (< f30-0 f28-0) (>= f30-0 (-> obj last-y))) (and (>= f30-0 f28-0) (< f30-0 (-> obj last-y))))
(set! (-> s5-0 quad) (-> obj collide-info trans quad))
(set! (-> s5-0 y) f30-0)
(dummy-13 (-> obj water) 1.0 s5-0 1 (-> obj collide-info transv))
)
(set! (-> obj last-y) f28-0)
)
)
((the-as (function nav-enemy none) (find-parent-method sharkey 39)) obj)
0
(none)
)
(defbehavior sharkey-notice-player? sharkey ()
(if *target*
(and (< (- (-> *target* control trans y) (-> self y-max)) 0.0)
(let ((gp-0 'racer)
(a1-0 (new 'stack-no-clear 'event-message-block))
)
(set! (-> a1-0 from) self)
(set! (-> a1-0 num-params) 1)
(set! (-> a1-0 message) 'query)
(set! (-> a1-0 param 0) (the-as uint 'mode))
(!= gp-0 (send-event-function *target* a1-0))
)
(nav-enemy-test-point-near-nav-mesh? (-> *target* control shadow-pos))
)
)
)
(defun sharkey-get-player-position ((arg0 vector))
(set! (-> arg0 quad) (-> (target-pos 5) quad))
0
(none)
)
(defbehavior sharkey-reset-position sharkey ()
(set! (-> self collide-info trans quad) (-> self entity extra trans quad))
0
(none)
)
(defbehavior sharkey-move-to-attack-position sharkey ()
(let ((s5-0 (new 'stack-no-clear 'vector))
(s3-0 (new 'stack-no-clear 'vector))
(gp-0 (new 'stack-no-clear 'vector))
)
(let ((s4-0 (-> *target* control trans)))
(let ((f30-0 4096000.0))
(set! (-> s3-0 quad) (-> self entity extra trans quad))
(set! (-> s5-0 quad) (-> self collide-info trans quad))
(dotimes (s2-0 (-> self path curve num-cverts))
(eval-path-curve-div! (-> self path) s3-0 (the float s2-0) 'interp)
(let ((f0-2 (vector-vector-xz-distance s4-0 s3-0)))
(when (< f0-2 f30-0)
(set! f30-0 f0-2)
(set! (-> s5-0 quad) (-> s3-0 quad))
)
)
)
)
(vector-! (-> self dir) s4-0 s5-0)
(vector-normalize! (-> self dir) 1.0)
(vector+*! gp-0 s4-0 (-> self dir) (- (-> self spawn-distance)))
)
(project-onto-nav-mesh (-> self nav) gp-0 gp-0)
(set! (-> gp-0 y) (-> self y-min))
(set! (-> self spawn-point quad) (-> gp-0 quad))
)
(set! (-> self collide-info trans quad) (-> self spawn-point quad))
(forward-up->quaternion (-> self collide-info quat) (-> self dir) *up-vector*)
(let ((f0-6 0.0))
(set! (-> self momentum-speed) f0-6)
f0-6
)
)
(defstate nav-enemy-idle (sharkey)
:virtual #t
:event
(the-as
(function process int symbol event-message-block object :behavior sharkey)
nav-enemy-default-event-handler
)
:enter
(behavior ()
(set! (-> self state-time) (-> *display* base-frame-counter))
(set! (-> self nav-enemy-flags) (logand -2 (-> self nav-enemy-flags)))
(none)
)
:exit
(behavior ()
(logclear! (-> self draw status) (draw-status hidden))
(none)
)
:trans
(behavior ()
(cond
((-> self enable-patrol)
(if (and (and *target* (>= (-> self enemy-info idle-distance)
(vector-vector-distance (-> self collide-info trans) (-> *target* control trans))
)
)
(>= (- (-> *display* base-frame-counter) (-> self state-time)) (-> self state-timeout))
)
(go-virtual nav-enemy-patrol)
)
)
((sharkey-notice-player?)
(when (zero? (logand (-> self nav-enemy-flags) 1))
(logior! (-> self nav-enemy-flags) 1)
(set! (-> self notice-time) (-> *display* base-frame-counter))
)
(let ((a0-4 (dummy-16 (-> self nav) (-> *target* control trans))))
(when (or (and a0-4 (logtest? (-> a0-4 pat) 2))
(and (logtest? (-> self draw status) (draw-status hidden))
(>= (- (-> *display* base-frame-counter) (-> self notice-time)) (-> self reaction-time))
)
)
(sharkey-move-to-attack-position)
(set! (-> self player-in-water) #t)
(go-virtual nav-enemy-chase)
)
)
)
(else
(if (>= (- (-> *display* base-frame-counter) (-> self notice-time)) (seconds 10))
(set! (-> self nav-enemy-flags) (logand -2 (-> self nav-enemy-flags)))
)
)
)
(none)
)
:code
(behavior ()
(ja-channel-push! 1 22)
(let ((v1-2 (-> self skel root-channel 0)))
(set! (-> v1-2 frame-group)
(the-as art-joint-anim (-> self draw art-group data (-> self nav-info idle-anim)))
)
)
(let ((v1-5 (-> self skel root-channel 0)))
(set! (-> v1-5 num-func) num-func-identity)
(set! (-> v1-5 frame-num) 0.0)
)
(until (= (-> self collide-info trans y) (-> self y-min))
(let ((a0-7 (-> self skel root-channel 0)))
(set! (-> a0-7 param 0) (-> self anim-speed))
(joint-control-channel-group-eval! a0-7 (the-as art-joint-anim #f) num-func-loop!)
)
(set! (-> self anim-speed) (seek (-> self anim-speed) 1.0 0.05))
(set! (-> self collide-info trans y)
(seek (-> self collide-info trans y) (-> self y-min) (* (-> self y-speed) (-> *display* seconds-per-frame)))
)
(dummy-10 (-> self water))
(ja-post)
(suspend)
)
(logior! (-> self draw status) (draw-status hidden))
(anim-loop)
(none)
)
:post
(the-as (function none :behavior sharkey) #f)
)
(defstate nav-enemy-patrol (sharkey)
:virtual #t
:event
(the-as
(function process int symbol event-message-block object :behavior sharkey)
nav-enemy-default-event-handler
)
:trans
(behavior ()
(if (sharkey-notice-player?)
(go-virtual nav-enemy-chase)
)
(none)
)
:code
(behavior ()
(ja-channel-push! 1 22)
(set! (-> self nav target-pos quad) (-> self spawn-point quad))
(while #t
(let ((a0-3 (-> self skel root-channel 0)))
(set! (-> a0-3 frame-group)
(the-as art-joint-anim (-> self draw art-group data (-> self nav-info walk-anim)))
)
(set! (-> a0-3 param 0)
(the float
(+ (-> (the-as art-joint-anim (-> self draw art-group data (-> self nav-info walk-anim))) data 0 length) -1)
)
)
(set! (-> a0-3 param 1) (-> self anim-speed))
(set! (-> a0-3 frame-num) 0.0)
(joint-control-channel-group!
a0-3
(the-as art-joint-anim (-> self draw art-group data (-> self nav-info walk-anim)))
num-func-seek!
)
)
(until (ja-done? 0)
(set! (-> self anim-speed) (seek (-> self anim-speed) 1.0 0.05))
(cond
((-> self enable-patrol)
(set! (-> self collide-info trans y)
(seek (-> self collide-info trans y) (-> self y-max) (* (-> self y-speed) (-> *display* seconds-per-frame)))
)
)
(else
(if (< (- (-> self collide-info trans y) (-> self y-min)) 409.6)
(go-virtual nav-enemy-idle)
)
)
)
(suspend)
(let ((a0-6 (-> self skel root-channel 0)))
(set! (-> a0-6 param 0) (the float (+ (-> a0-6 frame-group data 0 length) -1)))
(set! (-> a0-6 param 1) (-> self anim-speed))
(joint-control-channel-group-eval! a0-6 (the-as art-joint-anim #f) num-func-seek!)
)
)
)
(none)
)
:post
(behavior ()
(nav-enemy-travel-post)
(none)
)
)
(defstate nav-enemy-notice (sharkey)
:virtual #t
:event
(the-as
(function process int symbol event-message-block object :behavior sharkey)
nav-enemy-default-event-handler
)
:enter
(behavior ()
(go-virtual nav-enemy-chase)
(none)
)
:code
(behavior ()
(go-virtual nav-enemy-chase)
(none)
)
)
(defbehavior sharkey-follow-trajectory sharkey ((arg0 float))
(let ((gp-0 (-> self jump-trajectory)))
(eval-position! gp-0 arg0 (-> self collide-info trans))
(eval-velocity! gp-0 arg0 (-> self collide-info transv))
)
(vector-normalize-copy! (-> self dir) (-> self collide-info transv) 1.0)
(forward-up->quaternion (-> self collide-info quat) (-> self dir) *up-vector*)
)
(defstate nav-enemy-attack (sharkey)
:virtual #t
:event
(the-as
(function process int symbol event-message-block object :behavior sharkey)
nav-enemy-default-event-handler
)
:code
(behavior ()
(let ((gp-0 (new 'stack-no-clear 'vector))
(s5-0 (new 'stack-no-clear 'vector))
)
(-> *display* base-frame-counter)
(sound-play-by-name (static-sound-name "bigshark-bite") (new-sound-id) 1024 0 0 1 #t)
(set! (-> self state-time) (-> *display* base-frame-counter))
(set! (-> gp-0 quad) (-> self collide-info trans quad))
(ja-channel-push! 1 30)
(let ((s4-1 (-> self skel root-channel 0)))
(set! (-> s4-1 frame-group) (the-as art-joint-anim (-> self draw art-group data 3)))
(set! (-> s4-1 param 0) (ja-aframe 3.0 0))
(set! (-> s4-1 param 1) 2.0)
(set! (-> s4-1 frame-num) 0.0)
(joint-control-channel-group! s4-1 (the-as art-joint-anim (-> self draw art-group data 3)) num-func-seek!)
)
(until (ja-done? 0)
(sharkey-get-player-position s5-0)
(setup-from-to-duration! (-> self jump-trajectory) gp-0 s5-0 3.0 -291.27112)
(set! (-> self attack-time) (ja-aframe-num 0))
(sharkey-follow-trajectory (-> self attack-time))
(suspend)
(let ((s4-2 (-> self skel root-channel 0)))
(set! (-> s4-2 param 0) (ja-aframe 3.0 0))
(set! (-> s4-2 param 1) 2.0)
(joint-control-channel-group-eval! s4-2 (the-as art-joint-anim #f) num-func-seek!)
)
)
)
(let ((a1-7 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-7 from) self)
(set! (-> a1-7 num-params) 2)
(set! (-> a1-7 message) 'attack-invinc)
(set! (-> a1-7 param 0) (the-as uint #f))
(let ((a0-15 (new 'static 'attack-info :mask #x20)))
(set! (-> a0-15 mode) 'sharkey)
(set! (-> a1-7 param 1) (the-as uint a0-15))
)
(when (send-event-function *target* a1-7)
(logclear! (-> self mask) (process-mask enemy))
(vector-float*! (-> self collide-info transv) (-> self collide-info transv) 8.0)
(set! (-> self state-time) (-> *display* base-frame-counter))
(let ((f30-0 -409600.0)
(f28-0 (-> self collide-info transv y))
(f26-0 (-> self collide-info trans y))
)
(until (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 3))
(let ((gp-1 (-> self skel root-channel 0)))
(set! (-> gp-1 frame-group) (the-as art-joint-anim (-> self draw art-group data 3)))
(set! (-> gp-1 param 0)
(the float (+ (-> (the-as art-joint-anim (-> self draw art-group data 3)) data 0 length) -1))
)
(set! (-> gp-1 param 1) 1.0)
(set! (-> gp-1 frame-num) (ja-aframe 3.0 0))
(joint-control-channel-group! gp-1 (the-as art-joint-anim (-> self draw art-group data 3)) num-func-seek!)
)
(until (ja-done? 0)
(+! f28-0 (* f30-0 (-> *display* seconds-per-frame)))
(+! f26-0 (* f28-0 (-> *display* seconds-per-frame)))
(set! (-> self collide-info transv y) f28-0)
(when (< (-> self collide-info trans y) (-> self water height))
(set! f28-0 (* 0.9 f28-0))
(vector-float*! (-> self collide-info transv) (-> self collide-info transv) 0.9)
)
(vector-normalize-copy! (-> self dir) (-> self collide-info transv) 1.0)
(forward-up->quaternion (-> self collide-info quat) (-> self dir) *up-vector*)
(integrate-for-enemy-with-move-to-ground!
(-> self collide-info)
(-> self collide-info transv)
(collide-kind background)
8192.0
#t
#f
#f
)
(set! (-> self collide-info trans y) f26-0)
(suspend)
(let ((a0-27 (-> self skel root-channel 0)))
(set! (-> a0-27 param 0) (the float (+ (-> a0-27 frame-group data 0 length) -1)))
(set! (-> a0-27 param 1) 1.0)
(joint-control-channel-group-eval! a0-27 (the-as art-joint-anim #f) num-func-seek!)
)
)
)
)
(send-event *target* 'end-mode)
(set! (-> self mask) (logior (process-mask enemy) (-> self mask)))
)
)
(sharkey-reset-position)
(logior! (-> self draw status) (draw-status hidden))
(go-virtual nav-enemy-idle)
(none)
)
:post
(behavior ()
(nav-enemy-simple-post)
(none)
)
)
(defstate nav-enemy-chase (sharkey)
:virtual #t
:event
(the-as
(function process int symbol event-message-block object :behavior sharkey)
nav-enemy-default-event-handler
)
:exit
(behavior ()
(sound-stop (-> self sound-id))
(none)
)
:trans
(behavior ()
(if (not *target*)
(go-virtual nav-enemy-patrol)
)
(let ((gp-0 (-> *target* control trans)))
(let ((s5-0 (nav-enemy-test-point-near-nav-mesh? (-> *target* control shadow-pos)))
(s4-0 'racer)
(a1-0 (new 'stack-no-clear 'event-message-block))
)
(set! (-> a1-0 from) self)
(set! (-> a1-0 num-params) 1)
(set! (-> a1-0 message) 'query)
(set! (-> a1-0 param 0) (the-as uint 'mode))
(if (or (= s4-0 (send-event-function *target* a1-0)) (not s5-0))
(go-virtual nav-enemy-patrol)
)
)
(when (logtest? (-> *target* control status) 2)
(set! (-> self player-in-water) (logtest? (-> *target* control status) 1024))
(if (-> self player-in-water)
(set! (-> self player-water-time) (-> *display* base-frame-counter))
)
)
(if (and *target* (>= 8192.0 (vector-vector-distance (-> self collide-info trans) (-> *target* control trans))))
(go-virtual nav-enemy-attack)
)
(cond
((-> self player-in-water)
(set! (-> self free-time) (-> *display* base-frame-counter))
(if (and (< (fabs (- (-> gp-0 y) (-> self collide-info trans y))) 40960.0)
(< (vector-vector-xz-distance gp-0 (-> self collide-info trans)) 24576.0)
)
(go-virtual nav-enemy-attack)
)
)
(else
(if (>= (- (-> *display* base-frame-counter) (-> self free-time)) (seconds 3))
(go-virtual nav-enemy-patrol)
)
)
)
)
(let ((a0-10 (-> self nav target-poly)))
(if (and a0-10 (logtest? (-> a0-10 pat) 2))
(set! (-> self target-speed) (* 2.0 (-> self chase-speed)))
(set! (-> self target-speed) (-> self chase-speed))
)
)
(none)
)
:code
(behavior ()
(set! (-> self player-water-time) (-> *display* base-frame-counter))
(ja-channel-push! 1 51)
(sound-play-by-name (static-sound-name "bigshark-idle") (new-sound-id) 1024 0 0 1 #t)
(while #t
(let ((a0-3 (-> self skel root-channel 0)))
(set! (-> a0-3 frame-group) (the-as art-joint-anim (-> self draw art-group data (-> self nav-info run-anim))))
(set! (-> a0-3 param 0)
(the float
(+ (-> (the-as art-joint-anim (-> self draw art-group data (-> self nav-info run-anim))) data 0 length) -1)
)
)
(set! (-> a0-3 param 1) (-> self anim-speed))
(set! (-> a0-3 frame-num) 0.0)
(joint-control-channel-group!
a0-3
(the-as art-joint-anim (-> self draw art-group data (-> self nav-info run-anim)))
num-func-seek!
)
)
(until (ja-done? 0)
(set! (-> self anim-speed) (seek (-> self anim-speed) 1.0 (* 3.0 (-> *display* seconds-per-frame))))
(suspend)
(let ((a0-5 (-> self skel root-channel 0)))
(set! (-> a0-5 param 0) (the float (+ (-> a0-5 frame-group data 0 length) -1)))
(set! (-> a0-5 param 1) (-> self anim-speed))
(joint-control-channel-group-eval! a0-5 (the-as art-joint-anim #f) num-func-seek!)
)
)
)
(none)
)
:post
(behavior ()
(sharkey-get-player-position (-> self nav target-pos))
(nav-enemy-travel-post)
(let* ((f3-0 (vector-vector-distance (-> self collide-info trans) (-> self nav target-pos)))
(f1-2 (fmax 0.0 (fmin 1.0 (- 1.0 (/ (+ -24576.0 f3-0) (+ -24576.0 (-> self spawn-distance)))))))
(f0-2 (+ 0.5 (* 1.5 f1-2)))
)
(sound-play-by-name
(static-sound-name "bigshark-alert")
(-> self sound-id)
1024
(the int (* 1524.0 f0-2))
0
1
(the-as symbol (-> self collide-info trans))
)
)
(none)
)
)
(defstate nav-enemy-stop-chase (sharkey)
:virtual #t
:event
(the-as
(function process int symbol event-message-block object :behavior sharkey)
nav-enemy-default-event-handler
)
:code
(behavior ()
(ja-channel-push! 1 51)
(while #t
(let ((a0-1 (-> self skel root-channel 0)))
(set! (-> a0-1 frame-group)
(the-as art-joint-anim (-> self draw art-group data (-> self nav-info walk-anim)))
)
(set! (-> a0-1 param 0)
(the float
(+ (-> (the-as art-joint-anim (-> self draw art-group data (-> self nav-info walk-anim))) data 0 length) -1)
)
)
(set! (-> a0-1 param 1) (-> self anim-speed))
(set! (-> a0-1 frame-num) 0.0)
(joint-control-channel-group!
a0-1
(the-as art-joint-anim (-> self draw art-group data (-> self nav-info walk-anim)))
num-func-seek!
)
)
(until (ja-done? 0)
(set! (-> self anim-speed) (seek (-> self anim-speed) 1.0 0.05))
(set! (-> self collide-info trans y)
(seek (-> self collide-info trans y) (-> self y-max) (* (-> self y-speed) (-> *display* seconds-per-frame)))
)
(suspend)
(let ((a0-4 (-> self skel root-channel 0)))
(set! (-> a0-4 param 0) (the float (+ (-> a0-4 frame-group data 0 length) -1)))
(set! (-> a0-4 param 1) (-> self anim-speed))
(joint-control-channel-group-eval! a0-4 (the-as art-joint-anim #f) num-func-seek!)
)
)
)
(none)
)
)
(defstate nav-enemy-stare (sharkey)
:virtual #t
:event
(the-as
(function process int symbol event-message-block object :behavior sharkey)
nav-enemy-default-event-handler
)
:trans
(behavior ()
(if (TODO-RENAME-46 self (-> self nav-info notice-distance))
(go-virtual nav-enemy-chase)
)
(if (>= (- (-> *display* base-frame-counter) (-> self state-time)) (-> self state-timeout))
(go-virtual nav-enemy-patrol)
)
(none)
)
:code
(behavior ()
(ja-channel-push! 1 51)
(let ((v1-2 (-> self skel root-channel 0)))
(set! (-> v1-2 frame-group)
(the-as art-joint-anim (-> self draw art-group data (-> self nav-info idle-anim)))
)
)
(let ((v1-5 (-> self skel root-channel 0)))
(set! (-> v1-5 num-func) num-func-identity)
(set! (-> v1-5 frame-num) 0.0)
)
(while #t
(let ((a0-7 (-> self skel root-channel 0)))
(set! (-> a0-7 param 0) (-> self anim-speed))
(joint-control-channel-group-eval! a0-7 (the-as art-joint-anim #f) num-func-loop!)
)
(set! (-> self anim-speed) (seek (-> self anim-speed) 1.0 0.05))
(set! (-> self collide-info trans y)
(seek (-> self collide-info trans y) (-> self y-max) (* (-> self y-speed) (-> *display* seconds-per-frame)))
)
(suspend)
)
(none)
)
)
(defstate nav-enemy-victory (sharkey)
:virtual #t
:event
(the-as
(function process int symbol event-message-block object :behavior sharkey)
nav-enemy-default-event-handler
)
:code
(behavior ()
(ja-channel-push! 1 22)
(dotimes (gp-0 3)
(let ((a0-1 (-> self skel root-channel 0)))
(set! (-> a0-1 frame-group)
(the-as art-joint-anim (-> self draw art-group data (-> self nav-info victory-anim)))
)
(set! (-> a0-1 param 0)
(the float
(+ (-> (the-as art-joint-anim (-> self draw art-group data (-> self nav-info victory-anim))) data 0 length)
-1
)
)
)
(set! (-> a0-1 param 1) (-> self anim-speed))
(set! (-> a0-1 frame-num) 0.0)
(joint-control-channel-group!
a0-1
(the-as art-joint-anim (-> self draw art-group data (-> self nav-info victory-anim)))
num-func-seek!
)
)
(until (ja-done? 0)
(suspend)
(let ((a0-2 (-> self skel root-channel 0)))
(set! (-> a0-2 param 0) (the float (+ (-> a0-2 frame-group data 0 length) -1)))
(set! (-> a0-2 param 1) (-> self anim-speed))
(joint-control-channel-group-eval! a0-2 (the-as art-joint-anim #f) num-func-seek!)
)
)
)
(go-virtual nav-enemy-stare)
(none)
)
)
(define *sharkey-nav-enemy-info* (new 'static 'nav-enemy-info
:idle-anim 2
:walk-anim 2
:turn-anim -1
:notice-anim 2
:run-anim 2
:jump-anim -1
:jump-land-anim -1
:victory-anim 2
:taunt-anim 2
:die-anim 2
:neck-joint -1
:player-look-at-joint 5
:run-travel-speed (meters 12)
:run-rotate-speed (degrees 1999.9999)
:run-acceleration (meters 6)
:run-turn-time (seconds 0.5)
:walk-travel-speed (meters 6)
:walk-rotate-speed (degrees 1999.9999)
:walk-acceleration (meters 6)
:walk-turn-time (seconds 0.5)
:attack-shove-back (meters 1)
:attack-shove-up (meters 0.5)
:shadow-size (meters 2)
:notice-nav-radius (meters 3)
:nav-nearest-y-threshold (meters 10)
:notice-distance (meters 500)
:stop-chase-distance (meters 510)
:frustration-distance (meters 8)
:frustration-time (seconds 4)
:die-anim-hold-frame 10000000000.0
:jump-land-anim-end-frame 10000000000.0
:jump-height-min (meters 1)
:jump-height-factor 0.5
:jump-start-anim-speed 1.0
:shadow-max-y (meters 1)
:shadow-min-y (meters -1)
:shadow-locus-dist (meters 150)
:use-align #f
:draw-shadow #f
:move-to-ground #f
:hover-if-no-ground #f
:use-momentum #t
:use-flee #f
:use-proximity-notice #f
:use-jump-blocked #f
:use-jump-patrol #f
:gnd-collide-with #x1
:debug-draw-neck #f
:debug-draw-jump #f
)
)
(defmethod init-from-entity! sharkey ((obj sharkey) (arg0 entity-actor))
(set! (-> obj scale) (res-lump-float arg0 'scale :default 1.0))
(let ((s4-0 (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player))))
(set! (-> s4-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> s4-0 reaction) default-collision-reaction)
(set! (-> s4-0 no-reaction)
(the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing)
)
(let ((s3-0 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 1))))
(set! (-> s3-0 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-0 collide-with) (collide-kind target))
(set! (-> s3-0 prim-core offense) (collide-offense normal-attack))
(set-vector! (-> s3-0 local-sphere) 0.0 0.0 0.0 (* 6144.0 (-> obj scale)))
(set-root-prim! s4-0 s3-0)
)
(set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
(backup-collide-with-as s4-0)
(set! (-> obj collide-info) s4-0)
)
(process-drawable-from-entity! obj arg0)
(initialize-skeleton obj *sharkey-sg* '())
(TODO-RENAME-45 obj *sharkey-nav-enemy-info*)
(logclear! (-> obj mask) (process-mask actor-pause))
(set! (-> obj water) (new 'process 'water-control obj 3 12288.0 8192.0 2048.0))
(set! (-> obj water flags) (the-as uint #xc00002))
(set! (-> obj water height) (res-lump-float (-> obj entity) 'water-height))
(set! (-> obj water ripple-size) 20480.0)
(set! (-> obj spawn-point quad) (-> obj collide-info trans quad))
(set! (-> obj collide-info nav-radius) 8192.0)
(set! (-> obj nav nearest-y-threshold) 4096000.0)
(set! (-> obj y-max) (- (-> obj water height) (* 2048.0 (-> obj scale))))
(set! (-> obj y-min) (+ -49152.0 (-> obj y-max)))
(set! (-> obj collide-info trans y) (-> obj y-min))
(set! (-> obj anim-speed) 1.0)
(set-vector! (-> obj collide-info scale) (-> obj scale) (-> obj scale) (-> obj scale) 1.0)
(set! (-> obj reaction-time)
(the-as time-frame (the int (* 300.0 (res-lump-float (-> obj entity) 'delay :default 1.0))))
)
(set! (-> obj spawn-distance) (res-lump-float (-> obj entity) 'distance :default 122880.0))
(set! (-> obj chase-speed) (res-lump-float (-> obj entity) 'speed :default 49152.0))
(set! (-> obj y-speed) (-> obj chase-speed))
(set! (-> obj enable-patrol) #f)
(set! (-> obj sound-id) (new-sound-id))
(set! (-> obj enemy-info cam-vert) 49152.0)
(go (method-of-object obj nav-enemy-idle))
(none)
)