mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
cd68cb671e
Major change to how `deftype` shows up in our code: - the decompiler will no longer emit the `offset-assert`, `method-count-assert`, `size-assert` and `flag-assert` parameters. There are extremely few cases where having this in the decompiled code is helpful, as the types there come from `all-types` which already has those parameters. This also doesn't break type consistency because: - the asserts aren't compared. - the first step of the test uses `all-types`, which has the asserts, which will throw an error if they're bad. - the decompiler won't emit the `heap-base` parameter unless necessary now. - the decompiler will try its hardest to turn a fixed-offset field into an `overlay-at` field. It falls back to the old offset if all else fails. - `overlay-at` now supports field "dereferencing" to specify the offset that's within a field that's a structure, e.g.: ```lisp (deftype foobar (structure) ((vec vector :inline) (flags int32 :overlay-at (-> vec w)) ) ) ``` in this structure, the offset of `flags` will be 12 because that is the final offset of `vec`'s `w` field within this structure. - **removed ID from all method declarations.** IDs are only ever automatically assigned now. Fixes #3068. - added an `:overlay` parameter to method declarations, in order to declare a new method that goes on top of a previously-defined method. Syntax is `:overlay <method-name>`. Please do not ever use this. - added `state-methods` list parameter. This lets you quickly specify a list of states to be put in the method table. Same syntax as the `states` list parameter. The decompiler will try to put as many states in this as it can without messing with the method ID order. Also changes `defmethod` to make the first type definition (before the arguments) optional. The type can now be inferred from the first argument. Fixes #3093. --------- Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
646 lines
24 KiB
Common Lisp
646 lines
24 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 (seconds 0.4)
|
|
:linger-duration (seconds 2.6)
|
|
:flags (use-local-clock)
|
|
:bounds (static-bspherem 0 -12 0 14)
|
|
:parts ((sp-item 124 :flags (is-3d) :period (seconds 3) :length (seconds 0.21))
|
|
(sp-item 125 :period (seconds 3) :length (seconds 0.05))
|
|
(sp-item 126 :flags (is-3d) :period (seconds 3) :length (seconds 0.05))
|
|
(sp-item 127 :flags (is-3d) :period (seconds 3) :length (seconds 0.05))
|
|
(sp-item 128 :period (seconds 3) :length (seconds 0.035) :binding 129)
|
|
(sp-item 129 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
|
|
(sp-item 129 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
|
|
(sp-item 129 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
|
|
(sp-item 129 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
|
|
(sp-item 129 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
|
|
(sp-item 129 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
|
|
(sp-item 129 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
|
|
(sp-item 129 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
|
|
(sp-item 129 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
|
|
(sp-item 129 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
|
|
(sp-item 129 :flags (start-dead) :period (seconds 3) :length (seconds 0.4))
|
|
)
|
|
)
|
|
|
|
(deftype sharkey (nav-enemy)
|
|
((dir vector :inline)
|
|
(spawn-point vector :inline)
|
|
(scale float)
|
|
(anim-speed float)
|
|
(y-max meters)
|
|
(y-min meters)
|
|
(attack-time float)
|
|
(player-water-time time-frame)
|
|
(player-in-water basic)
|
|
(last-y float)
|
|
(spawn-distance meters)
|
|
(chase-speed meters)
|
|
(y-speed meters)
|
|
(sound-id sound-id)
|
|
(enable-patrol basic)
|
|
)
|
|
)
|
|
|
|
|
|
(defskelgroup *sharkey-sg* sharkey sharkey-lod0-jg sharkey-idle-ja
|
|
((sharkey-lod0-mg (meters 999999)))
|
|
:bounds (static-spherem 0 0 0 6)
|
|
)
|
|
|
|
(defmethod touch-handler ((this sharkey) (arg0 process) (arg1 event-message-block))
|
|
#t
|
|
)
|
|
|
|
(defmethod attack-handler ((this sharkey) (arg0 process) (arg1 event-message-block))
|
|
#t
|
|
)
|
|
|
|
nav-enemy-default-event-handler
|
|
|
|
(defmethod run-logic? ((this sharkey))
|
|
(or (not (logtest? (-> this mask) (process-mask actor-pause)))
|
|
(or (>= (+ (-> *ACTOR-bank* pause-dist) (-> this collide-info pause-adjust-distance))
|
|
(vector-vector-distance (-> this collide-info trans) (math-camera-pos))
|
|
)
|
|
(and (nonzero? (-> this skel)) (!= (-> this skel root-channel 0) (-> this skel channel)))
|
|
(and (nonzero? (-> this draw)) (logtest? (-> this draw status) (draw-status no-skeleton-update)))
|
|
)
|
|
)
|
|
)
|
|
|
|
(defmethod nav-enemy-method-40 ((this sharkey))
|
|
(nav-control-method-11 (-> this nav) (-> this nav target-pos))
|
|
(let* ((f0-0 (vector-vector-xz-distance (-> this collide-info trans) (-> this nav target-pos)))
|
|
(f30-0 (/ (- (fmin (-> this y-max) (-> this nav target-pos y)) (-> this collide-info trans y)) f0-0))
|
|
)
|
|
(set! (-> this nav travel y) (* 4.0 (vector-length (-> this nav travel)) f30-0))
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod nav-enemy-method-37 ((this sharkey))
|
|
(let ((s5-0 (new 'stack-no-clear 'vector)))
|
|
(when (< 8192.0 (vector-length (-> this nav travel)))
|
|
(vector-normalize-copy! s5-0 (-> this nav travel) 1.0)
|
|
(vector-deg-seek (-> this dir) (-> this dir) s5-0 (* 65536.0 (seconds-per-frame)))
|
|
(vector-normalize! (-> this dir) 1.0)
|
|
(forward-up->quaternion (-> this collide-info quat) (-> this dir) *up-vector*)
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod nav-enemy-method-41 ((this sharkey))
|
|
(let* ((f0-1 (- (-> this target-speed) (-> this momentum-speed)))
|
|
(f1-3 (fmin (* (-> this acceleration) (seconds-per-frame)) (fabs f0-1)))
|
|
)
|
|
(if (< f0-1 0.0)
|
|
(set! (-> this momentum-speed) (- (-> this momentum-speed) f1-3))
|
|
(+! (-> this momentum-speed) f1-3)
|
|
)
|
|
)
|
|
(let ((f0-9 (fmin
|
|
(* (-> this speed-scale) (-> this momentum-speed))
|
|
(* (vector-length (-> this nav travel)) (-> *display* frames-per-second))
|
|
)
|
|
)
|
|
)
|
|
(vector-normalize-copy! (-> this collide-info transv) (-> this nav travel) f0-9)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod common-post ((this sharkey))
|
|
(let ((f30-0 (-> this water height))
|
|
(s5-0 (new 'stack-no-clear 'vector))
|
|
)
|
|
(let* ((f3-0 (- -36864.0 (-> this collide-info trans y)))
|
|
(f0-2 (fmax 0.0 (fmin 1.0 (- 1.0 (* 0.00008138021 f3-0)))))
|
|
)
|
|
(set-vector! (-> this draw color-mult) f0-2 f0-2 f0-2 1.0)
|
|
)
|
|
(water-control-method-10 (-> this water))
|
|
(let ((f28-0 (-> this collide-info trans y)))
|
|
(when (or (and (< f30-0 f28-0) (>= f30-0 (-> this last-y))) (and (>= f30-0 f28-0) (< f30-0 (-> this last-y))))
|
|
(set! (-> s5-0 quad) (-> this collide-info trans quad))
|
|
(set! (-> s5-0 y) f30-0)
|
|
(create-splash (-> this water) 1.0 s5-0 1 (-> this collide-info transv))
|
|
)
|
|
(set! (-> this last-y) f28-0)
|
|
)
|
|
)
|
|
(call-parent-method this)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defbehavior sharkey-notice-player? sharkey ()
|
|
(if *target*
|
|
(and (< (- (-> *target* control trans y) (-> self y-max)) 0.0)
|
|
(let ((gp-0 'racer))
|
|
(!= gp-0 (send-event *target* 'query 'mode))
|
|
)
|
|
(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*)
|
|
(set! (-> self momentum-speed) 0.0)
|
|
)
|
|
|
|
(defstate nav-enemy-idle (sharkey)
|
|
:virtual #t
|
|
:event nav-enemy-default-event-handler
|
|
:enter (behavior ()
|
|
(set-time! (-> self state-time))
|
|
(logclear! (-> self nav-enemy-flags) (nav-enemy-flags navenmf0))
|
|
)
|
|
:exit (behavior ()
|
|
(logclear! (-> self draw status) (draw-status hidden))
|
|
)
|
|
: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))
|
|
)
|
|
)
|
|
(time-elapsed? (-> self state-time) (-> self state-timeout))
|
|
)
|
|
(go-virtual nav-enemy-patrol)
|
|
)
|
|
)
|
|
((sharkey-notice-player?)
|
|
(when (not (logtest? (-> self nav-enemy-flags) (nav-enemy-flags navenmf0)))
|
|
(logior! (-> self nav-enemy-flags) (nav-enemy-flags navenmf0))
|
|
(set-time! (-> self notice-time))
|
|
)
|
|
(let ((a0-4 (nav-control-method-16 (-> self nav) (-> *target* control trans))))
|
|
(when (or (and a0-4 (logtest? (-> a0-4 pat) 2)) (and (logtest? (-> self draw status) (draw-status hidden))
|
|
(time-elapsed? (-> self notice-time) (-> self reaction-time))
|
|
)
|
|
)
|
|
(sharkey-move-to-attack-position)
|
|
(set! (-> self player-in-water) #t)
|
|
(go-virtual nav-enemy-chase)
|
|
)
|
|
)
|
|
)
|
|
(else
|
|
(if (time-elapsed? (-> self notice-time) (seconds 10))
|
|
(logclear! (-> self nav-enemy-flags) (nav-enemy-flags navenmf0))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
:code (behavior ()
|
|
(ja-channel-push! 1 (seconds 0.075))
|
|
(ja :group! (-> self draw art-group data (-> self nav-info idle-anim)))
|
|
(ja :num-func num-func-identity :frame-num 0.0)
|
|
(until (= (-> self collide-info trans y) (-> self y-min))
|
|
(ja :num! (loop! (-> self anim-speed)))
|
|
(seek! (-> self anim-speed) 1.0 0.05)
|
|
(seek! (-> self collide-info trans y) (-> self y-min) (* (-> self y-speed) (seconds-per-frame)))
|
|
(water-control-method-10 (-> self water))
|
|
(ja-post)
|
|
(suspend)
|
|
)
|
|
(logior! (-> self draw status) (draw-status hidden))
|
|
(anim-loop)
|
|
)
|
|
:post #f
|
|
)
|
|
|
|
(defstate nav-enemy-patrol (sharkey)
|
|
:virtual #t
|
|
:event nav-enemy-default-event-handler
|
|
:trans (behavior ()
|
|
(if (sharkey-notice-player?)
|
|
(go-virtual nav-enemy-chase)
|
|
)
|
|
)
|
|
:code (behavior ()
|
|
(ja-channel-push! 1 (seconds 0.075))
|
|
(set! (-> self nav target-pos quad) (-> self spawn-point quad))
|
|
(loop
|
|
(ja-no-eval :group! (-> self draw art-group data (-> self nav-info walk-anim))
|
|
:num! (seek! max (-> self anim-speed))
|
|
:frame-num 0.0
|
|
)
|
|
(until (ja-done? 0)
|
|
(seek! (-> self anim-speed) 1.0 0.05)
|
|
(cond
|
|
((-> self enable-patrol)
|
|
(seek! (-> self collide-info trans y) (-> self y-max) (* (-> self y-speed) (seconds-per-frame)))
|
|
)
|
|
(else
|
|
(if (< (- (-> self collide-info trans y) (-> self y-min)) 409.6)
|
|
(go-virtual nav-enemy-idle)
|
|
)
|
|
)
|
|
)
|
|
(suspend)
|
|
(ja :num! (seek! max (-> self anim-speed)))
|
|
)
|
|
)
|
|
)
|
|
:post (behavior ()
|
|
(nav-enemy-travel-post)
|
|
)
|
|
)
|
|
|
|
(defstate nav-enemy-notice (sharkey)
|
|
:virtual #t
|
|
:event nav-enemy-default-event-handler
|
|
:enter (behavior ()
|
|
(go-virtual nav-enemy-chase)
|
|
)
|
|
:code (behavior ()
|
|
(go-virtual nav-enemy-chase)
|
|
)
|
|
)
|
|
|
|
(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 nav-enemy-default-event-handler
|
|
:code (behavior ()
|
|
(let ((gp-0 (new 'stack-no-clear 'vector))
|
|
(s5-0 (new 'stack-no-clear 'vector))
|
|
)
|
|
(current-time)
|
|
(sound-play "bigshark-bite")
|
|
(set-time! (-> self state-time))
|
|
(set! (-> gp-0 quad) (-> self collide-info trans quad))
|
|
(ja-channel-push! 1 (seconds 0.1))
|
|
(ja-no-eval :group! sharkey-chomp-ja :num! (seek! (ja-aframe 3.0 0) 2.0) :frame-num 0.0)
|
|
(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)
|
|
(ja :num! (seek! (ja-aframe 3.0 0) 2.0))
|
|
)
|
|
)
|
|
(when (send-event *target* 'attack-invinc #f (static-attack-info ((mode 'sharkey))))
|
|
(logclear! (-> self mask) (process-mask enemy))
|
|
(vector-float*! (-> self collide-info transv) (-> self collide-info transv) 8.0)
|
|
(set-time! (-> self state-time))
|
|
(let ((f30-0 -409600.0)
|
|
(f28-0 (-> self collide-info transv y))
|
|
(f26-0 (-> self collide-info trans y))
|
|
)
|
|
(until (time-elapsed? (-> self state-time) (seconds 3))
|
|
(ja-no-eval :group! sharkey-chomp-ja :num! (seek!) :frame-num (ja-aframe 3.0 0))
|
|
(until (ja-done? 0)
|
|
(+! f28-0 (* f30-0 (seconds-per-frame)))
|
|
(+! f26-0 (* f28-0 (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)
|
|
(ja :num! (seek!))
|
|
)
|
|
)
|
|
)
|
|
(send-event *target* 'end-mode)
|
|
(logior! (-> self mask) (process-mask enemy))
|
|
)
|
|
(sharkey-reset-position)
|
|
(logior! (-> self draw status) (draw-status hidden))
|
|
(go-virtual nav-enemy-idle)
|
|
)
|
|
:post (behavior ()
|
|
(nav-enemy-simple-post)
|
|
)
|
|
)
|
|
|
|
(defstate nav-enemy-chase (sharkey)
|
|
:virtual #t
|
|
:event nav-enemy-default-event-handler
|
|
:exit (behavior ()
|
|
(sound-stop (-> self sound-id))
|
|
)
|
|
: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) (cshape-moving-flags onground))
|
|
(set! (-> self player-in-water) (logtest? (-> *target* control status) (cshape-moving-flags on-water)))
|
|
(if (-> self player-in-water)
|
|
(set-time! (-> self player-water-time))
|
|
)
|
|
)
|
|
(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-time! (-> self free-time))
|
|
(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 (time-elapsed? (-> 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))
|
|
)
|
|
)
|
|
)
|
|
:code (behavior ()
|
|
(set-time! (-> self player-water-time))
|
|
(ja-channel-push! 1 (seconds 0.17))
|
|
(sound-play "bigshark-idle")
|
|
(loop
|
|
(ja-no-eval :group! (-> self draw art-group data (-> self nav-info run-anim))
|
|
:num! (seek! max (-> self anim-speed))
|
|
:frame-num 0.0
|
|
)
|
|
(until (ja-done? 0)
|
|
(seek! (-> self anim-speed) 1.0 (* 3.0 (seconds-per-frame)))
|
|
(suspend)
|
|
(ja :num! (seek! max (-> self anim-speed)))
|
|
)
|
|
)
|
|
)
|
|
: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
|
|
"bigshark-alert"
|
|
:id (-> self sound-id)
|
|
:pitch f0-2
|
|
:position (the-as symbol (-> self collide-info trans))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
(defstate nav-enemy-stop-chase (sharkey)
|
|
:virtual #t
|
|
:event nav-enemy-default-event-handler
|
|
:code (behavior ()
|
|
(ja-channel-push! 1 (seconds 0.17))
|
|
(loop
|
|
(ja-no-eval :group! (-> self draw art-group data (-> self nav-info walk-anim))
|
|
:num! (seek! max (-> self anim-speed))
|
|
:frame-num 0.0
|
|
)
|
|
(until (ja-done? 0)
|
|
(seek! (-> self anim-speed) 1.0 0.05)
|
|
(seek! (-> self collide-info trans y) (-> self y-max) (* (-> self y-speed) (seconds-per-frame)))
|
|
(suspend)
|
|
(ja :num! (seek! max (-> self anim-speed)))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
(defstate nav-enemy-stare (sharkey)
|
|
:virtual #t
|
|
:event nav-enemy-default-event-handler
|
|
:trans (behavior ()
|
|
(if (target-in-range? self (-> self nav-info notice-distance))
|
|
(go-virtual nav-enemy-chase)
|
|
)
|
|
(if (time-elapsed? (-> self state-time) (-> self state-timeout))
|
|
(go-virtual nav-enemy-patrol)
|
|
)
|
|
)
|
|
:code (behavior ()
|
|
(ja-channel-push! 1 (seconds 0.17))
|
|
(ja :group! (-> self draw art-group data (-> self nav-info idle-anim)))
|
|
(ja :num-func num-func-identity :frame-num 0.0)
|
|
(loop
|
|
(ja :num! (loop! (-> self anim-speed)))
|
|
(seek! (-> self anim-speed) 1.0 0.05)
|
|
(seek! (-> self collide-info trans y) (-> self y-max) (* (-> self y-speed) (seconds-per-frame)))
|
|
(suspend)
|
|
)
|
|
)
|
|
)
|
|
|
|
(defstate nav-enemy-victory (sharkey)
|
|
:virtual #t
|
|
:event nav-enemy-default-event-handler
|
|
:code (behavior ()
|
|
(ja-channel-push! 1 (seconds 0.075))
|
|
(dotimes (gp-0 3)
|
|
(ja-no-eval :group! (-> self draw art-group data (-> self nav-info victory-anim))
|
|
:num! (seek! max (-> self anim-speed))
|
|
:frame-num 0.0
|
|
)
|
|
(until (ja-done? 0)
|
|
(suspend)
|
|
(ja :num! (seek! max (-> self anim-speed)))
|
|
)
|
|
)
|
|
(go-virtual nav-enemy-stare)
|
|
)
|
|
)
|
|
|
|
(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 (collide-kind background)
|
|
:debug-draw-neck #f
|
|
:debug-draw-jump #f
|
|
)
|
|
)
|
|
|
|
(defmethod init-from-entity! ((this sharkey) (arg0 entity-actor))
|
|
(set! (-> this scale) (res-lump-float arg0 'scale :default 1.0))
|
|
(let ((s4-0 (new 'process 'collide-shape-moving this (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 (-> this 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! (-> this collide-info) s4-0)
|
|
)
|
|
(process-drawable-from-entity! this arg0)
|
|
(initialize-skeleton this *sharkey-sg* '())
|
|
(init-defaults! this *sharkey-nav-enemy-info*)
|
|
(logclear! (-> this mask) (process-mask actor-pause))
|
|
(set! (-> this water) (new 'process 'water-control this 3 12288.0 8192.0 2048.0))
|
|
(set! (-> this water flags) (water-flags wt01 wt22 wt23))
|
|
(set! (-> this water height) (res-lump-float (-> this entity) 'water-height))
|
|
(set! (-> this water ripple-size) 20480.0)
|
|
(set! (-> this spawn-point quad) (-> this collide-info trans quad))
|
|
(set! (-> this collide-info nav-radius) 8192.0)
|
|
(set! (-> this nav nearest-y-threshold) 4096000.0)
|
|
(set! (-> this y-max) (- (-> this water height) (* 2048.0 (-> this scale))))
|
|
(set! (-> this y-min) (+ -49152.0 (-> this y-max)))
|
|
(set! (-> this collide-info trans y) (-> this y-min))
|
|
(set! (-> this anim-speed) 1.0)
|
|
(set-vector! (-> this collide-info scale) (-> this scale) (-> this scale) (-> this scale) 1.0)
|
|
(set! (-> this reaction-time)
|
|
(the-as time-frame (the int (* 300.0 (res-lump-float (-> this entity) 'delay :default 1.0))))
|
|
)
|
|
(set! (-> this spawn-distance) (res-lump-float (-> this entity) 'distance :default 122880.0))
|
|
(set! (-> this chase-speed) (res-lump-float (-> this entity) 'speed :default 49152.0))
|
|
(set! (-> this y-speed) (-> this chase-speed))
|
|
(set! (-> this enable-patrol) #f)
|
|
(set! (-> this sound-id) (new-sound-id))
|
|
(set! (-> this enemy-info cam-vert) 49152.0)
|
|
(go (method-of-object this nav-enemy-idle))
|
|
(none)
|
|
)
|