jak-project/goal_src/jak1/levels/sunken/double-lurker.gc
Tyler Wilding c162c66118
g/j1: Cleanup all main issues in the formatter and format all of goal_src/jak1 (#3535)
This PR does two main things:
1. Work through the main low-hanging fruit issues in the formatter
keeping it from feeling mature and usable
2. Iterate and prove that point by formatting all of the Jak 1 code
base. **This has removed around 100K lines in total.**
- The decompiler will now format it's results for jak 1 to keep things
from drifting back to where they were. This is controlled by a new
config flag `format_code`.

How am I confident this hasn't broken anything?:
- I compiled the entire project and stored it's `out/jak1/obj` files
separately
- I then recompiled the project after formatting and wrote a script that
md5's each file and compares it (`compare-compilation-outputs.py`
- The results (eventually) were the same:

![Screenshot 2024-05-25
132900](https://github.com/open-goal/jak-project/assets/13153231/015e6f20-8d19-49b7-9951-97fa88ddc6c2)
> This proves that the only difference before and after is non-critical
whitespace for all code/macros that is actually in use.

I'm still aware of improvements that could be made to the formatter, as
well as general optimization of it's performance. But in general these
are for rare or non-critical situations in my opinion and I'll work
through them before doing Jak 2. The vast majority looks great and is
working properly at this point. Those known issues are the following if
you are curious:

![image](https://github.com/open-goal/jak-project/assets/13153231/0edfaba1-6d36-40f5-ab23-0642209867c4)
2024-06-05 22:17:31 -04:00

833 lines
36 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
(bundles "SUN.DGO")
(require "levels/misty/muse.gc")
(declare-type double-lurker nav-enemy)
;; DECOMP BEGINS
(deftype double-lurker-top (nav-enemy)
((parent-process (pointer double-lurker) :overlay-at parent)
(fall-dest vector :inline))
(:states (double-lurker-top-knocked-down object vector vector)
double-lurker-top-on-shoulders
double-lurker-top-on-shoulders-die
double-lurker-top-resume))
(deftype double-lurker (nav-enemy)
((knocked-back-speed float)
(buddy-on-shoulders? symbol)
(dead? symbol)
(buddy-dead? symbol)
(buddy-handle handle))
(:methods
(initialize-collision (_type_) collide-shape-moving :replace)
(double-lurker-method-53 (_type_ vector) symbol :overlay-at nav-enemy-method-53))
(:states
double-lurker-both-knocked-back
double-lurker-break-apart
double-lurker-buddy-was-hit
double-lurker-knocked-back
double-lurker-resume
double-lurker-show-anims
double-lurker-waiting-to-die))
(defskelgroup *double-lurker-sg*
double-lurker
double-lurker-lod0-jg
double-lurker-both-idle-ja
((double-lurker-lod0-mg (meters 20)) (double-lurker-lod1-mg (meters 40)) (double-lurker-lod2-mg (meters 999999)))
:bounds (static-spherem 0 1 0 4.5)
:longest-edge (meters 1)
:shadow double-lurker-shadow-mg)
(defskelgroup *double-lurker-top-sg*
double-lurker-top
double-lurker-top-lod0-jg
-1
((double-lurker-top-lod0-mg (meters 20))
(double-lurker-top-lod1-mg (meters 40))
(double-lurker-top-lod2-mg (meters 999999)))
:bounds (static-spherem 0 0.5 0 4.5)
:longest-edge (meters 1)
:shadow double-lurker-top-shadow-mg)
(define *double-lurker-top-nav-enemy-info*
(new 'static
'nav-enemy-info
:idle-anim 12
:walk-anim 13
:turn-anim -1
:notice-anim 14
:run-anim 15
:jump-anim -1
:jump-land-anim -1
:victory-anim 16
:taunt-anim 16
:die-anim 17
:neck-joint -1
:player-look-at-joint 5
:run-travel-speed (meters 6)
:run-rotate-speed (degrees 2880)
:run-acceleration (meters 1)
:run-turn-time (seconds 0.1)
:walk-travel-speed (meters 3)
:walk-rotate-speed (degrees 720)
:walk-acceleration (meters 1)
:walk-turn-time (seconds 0.5)
:attack-shove-back (meters 3)
:attack-shove-up (meters 2)
:shadow-size (meters 3)
:notice-nav-radius (meters 2)
:nav-nearest-y-threshold (meters 10)
:notice-distance (meters 30)
:stop-chase-distance (meters 40)
:frustration-distance (meters 8)
:frustration-time (seconds 4)
:die-anim-hold-frame 24.0
:jump-anim-start-frame 10.0
:jump-land-anim-end-frame 10000000000.0
:jump-height-min (meters 3)
:jump-height-factor 0.5
:jump-start-anim-speed 1.0
:shadow-max-y (meters 0.25)
:shadow-min-y (meters -1)
:shadow-locus-dist (meters 150)
:use-align #f
:draw-shadow #t
:move-to-ground #t
:hover-if-no-ground #f
:use-momentum #f
: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))
(define *double-lurker-when-both-nav-enemy-info*
(new 'static
'nav-enemy-info
:idle-anim 5
:walk-anim 6
:turn-anim -1
:notice-anim 7
:run-anim 8
:jump-anim -1
:jump-land-anim -1
:victory-anim 9
:taunt-anim 9
:die-anim 17
:neck-joint 5
:player-look-at-joint 5
:run-travel-speed (meters 6)
:run-rotate-speed (degrees 720)
:run-acceleration (meters 1)
:run-turn-time (seconds 0.1)
:walk-travel-speed (meters 3.8)
:walk-rotate-speed (degrees 720)
:walk-acceleration (meters 1)
:walk-turn-time (seconds 0.5)
:attack-shove-back (meters 3)
:attack-shove-up (meters 2)
:shadow-size (meters 4)
:notice-nav-radius (meters 2)
:nav-nearest-y-threshold (meters 10)
:notice-distance (meters 30)
:stop-chase-distance (meters 40)
:frustration-distance (meters 8)
:frustration-time (seconds 4)
:die-anim-hold-frame 24.0
:jump-anim-start-frame 10.0
:jump-land-anim-end-frame 10000000000.0
:jump-height-min (meters 3)
:jump-height-factor 0.5
:jump-start-anim-speed 1.0
:shadow-max-y (meters 0.25)
:shadow-min-y (meters -1)
:shadow-locus-dist (meters 150)
:use-align #f
:draw-shadow #t
:move-to-ground #t
:hover-if-no-ground #f
:use-momentum #f
: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))
(define *double-lurker-nav-enemy-info*
(new 'static
'nav-enemy-info
:idle-anim 12
:walk-anim 13
:turn-anim -1
:notice-anim 14
:run-anim 15
:jump-anim -1
:jump-land-anim -1
:victory-anim 16
:taunt-anim 16
:die-anim 17
:neck-joint 5
:player-look-at-joint 5
:run-travel-speed (meters 6)
:run-rotate-speed (degrees 720)
:run-acceleration (meters 1)
:run-turn-time (seconds 0.1)
:walk-travel-speed (meters 3.8)
:walk-rotate-speed (degrees 720)
:walk-acceleration (meters 1)
:walk-turn-time (seconds 0.5)
:attack-shove-back (meters 3)
:attack-shove-up (meters 2)
:shadow-size (meters 4)
:notice-nav-radius (meters 2)
:nav-nearest-y-threshold (meters 10)
:notice-distance (meters 30)
:stop-chase-distance (meters 40)
:frustration-distance (meters 8)
:frustration-time (seconds 4)
:die-anim-hold-frame 24.0
:jump-anim-start-frame 10.0
:jump-land-anim-end-frame 10000000000.0
:jump-height-min (meters 3)
:jump-height-factor 0.5
:jump-start-anim-speed 1.0
:shadow-max-y (meters 0.25)
:shadow-min-y (meters -1)
:shadow-locus-dist (meters 150)
:use-align #f
:draw-shadow #t
:move-to-ground #t
:hover-if-no-ground #f
:use-momentum #f
: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))
(defstate double-lurker-top-on-shoulders (double-lurker-top)
:event
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('trigger)
(let ((v1-1 (-> self fall-dest))
(a0-4 (-> (the-as vector (-> block param 0)) quad)))
(set! (-> v1-1 quad) a0-4)
(go double-lurker-top-knocked-down a0-4 (the-as vector argc) (the-as vector message))))
(('instant-death)
(let ((v1-3 (the-as object (-> block param 0))))
(quaternion-axis-angle! (-> self collide-info quat)
0.0
1.0
0.0
(atan (-> (the-as vector v1-3) x) (-> (the-as vector v1-3) z))))
(go double-lurker-top-on-shoulders-die))))
:code
(behavior ()
(loop
(clone-anim-once (ppointer->handle (-> self parent-process)) (the-as int (-> self draw origin-joint-index)) #t "")
(update-transforms! (-> self collide-info))
(suspend))))
(defstate double-lurker-top-on-shoulders-die (double-lurker-top)
:code
(behavior ()
(logclear! (-> self mask) (process-mask actor-pause))
(ja-channel-push! 1 (seconds 0.1))
(ja-no-eval :group! double-lurker-top-on-shoulders-die-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!))))
:post ja-post)
(defstate double-lurker-top-knocked-down (double-lurker-top)
:event
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('touch)
(send-event proc 'shove (-> block param 0) (static-attack-info ((shove-up (meters 3)) (shove-back (meters 2))))))))
:code
(behavior ((arg0 object) (arg1 vector) (arg2 vector))
(nav-enemy-method-51 self)
(let ((v1-3 (-> self draw shadow-ctrl))) (logclear! (-> v1-3 settings flags) (shadow-flags disable-draw)))
0
(logclear! (-> self collide-info nav-flags) (nav-flags navf0))
(logior! (-> self collide-info nav-flags) (nav-flags navf1))
(set! (-> self nav extra-nav-sphere quad) (-> self fall-dest quad))
(set! (-> self nav extra-nav-sphere w) 9011.2)
(let ((gp-0 (new 'stack-no-clear 'vector)))
(set! (-> gp-0 quad) (-> self collide-info trans quad))
(ja-channel-push! 1 (seconds 0.1))
(ja-no-eval :group! double-lurker-top-both-break-apart-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(vector-lerp! (-> self collide-info trans) gp-0 (-> self fall-dest) (fmin 1.0 (/ (ja-frame-num 0) (ja-aframe 44.0 0))))
(suspend)
(ja :num! (seek!))))
(logior! (-> self collide-info nav-flags) (nav-flags navf0))
(logclear! (-> self collide-info nav-flags) (nav-flags navf1))
(nav-control-method-27 (-> self nav))
(go double-lurker-top-resume))
:post transform-post)
(defstate double-lurker-top-resume (double-lurker-top)
:code
(behavior ()
(cond
((not *target*) (go-virtual nav-enemy-idle))
((target-in-range? self (-> self nav-info notice-distance)) (go-virtual nav-enemy-chase))
((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))
(nonzero? (-> self draw))
(logtest? (-> self draw status) (draw-status was-drawn)))
(go-virtual nav-enemy-patrol)))
(go-virtual nav-enemy-idle)))
(defstate nav-enemy-patrol (double-lurker-top)
:virtual #t
:code
(behavior ()
(ja-channel-push! 1 (seconds 0.2))
(ja :group! (-> self draw art-group data (-> self nav-info walk-anim)))
(ja :num-func num-func-identity :frame-num 0.0)
(let ((t9-1 (-> (method-of-type nav-enemy nav-enemy-patrol) code))) (if t9-1 ((the-as (function none) t9-1))))))
(defstate nav-enemy-die (double-lurker-top)
:virtual #t
:enter
(behavior ()
(let ((v1-2 (-> self entity extra perm)))
(logior! (-> v1-2 status) (entity-perm-status user-set-from-cstage))
(set! (-> v1-2 user-int8 1) 1))
(set! (-> self parent-process 0 dead?) #t)
(let ((t9-0 (-> (method-of-type nav-enemy nav-enemy-die) enter))) (if t9-0 (t9-0)))))
(defmethod nav-enemy-method-51 ((this double-lurker-top))
(restore-collide-with-as (-> this collide-info))
(logior! (-> this collide-info nav-flags) (nav-flags navf0))
(nav-control-method-27 (-> this nav))
(none))
(defmethod initialize-collision ((this double-lurker-top))
(let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum hit-by-player))))
(set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> s5-0 reaction) default-collision-reaction)
(set! (-> s5-0 no-reaction) (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing))
(let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 6) 0)))
(set! (-> s4-0 prim-core collide-as) (collide-kind enemy))
(set! (-> s4-0 collide-with) (collide-kind target))
(set! (-> s4-0 prim-core action) (collide-action solid))
(set-vector! (-> s4-0 local-sphere) 0.0 10240.0 0.0 14336.0)
(set-root-prim! s5-0 s4-0)
(let ((s3-0 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
(set! (-> s3-0 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-0 collide-with) (collide-kind target))
(set! (-> s3-0 prim-core action) (collide-action solid))
(set! (-> s3-0 prim-core offense) (collide-offense touch))
(set-vector! (-> s3-0 local-sphere) 0.0 2662.4 0.0 4096.0)
(append-prim s4-0 s3-0))
(let ((s3-1 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
(set! (-> s3-1 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-1 collide-with) (collide-kind target))
(set! (-> s3-1 prim-core action) (collide-action solid))
(set! (-> s3-1 prim-core offense) (collide-offense touch))
(set-vector! (-> s3-1 local-sphere) 0.0 6758.4 0.0 4096.0)
(append-prim s4-0 s3-1))
(let ((s3-2 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
(set! (-> s3-2 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-2 collide-with) (collide-kind target))
(set! (-> s3-2 prim-core action) (collide-action solid))
(set! (-> s3-2 prim-core offense) (collide-offense touch))
(set-vector! (-> s3-2 local-sphere) 0.0 10854.4 0.0 4096.0)
(append-prim s4-0 s3-2))
(let ((s3-3 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
(set! (-> s3-3 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-3 collide-with) (collide-kind target))
(set! (-> s3-3 prim-core offense) (collide-offense normal-attack))
(set! (-> s3-3 transform-index) 10)
(set-vector! (-> s3-3 local-sphere) 0.0 0.0 0.0 1228.8)
(append-prim s4-0 s3-3))
(let ((s3-4 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
(set! (-> s3-4 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-4 collide-with) (collide-kind target))
(set! (-> s3-4 prim-core offense) (collide-offense normal-attack))
(set! (-> s3-4 transform-index) 16)
(set-vector! (-> s3-4 local-sphere) 0.0 0.0 0.0 1228.8)
(append-prim s4-0 s3-4))
(let ((s3-5 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
(set! (-> s3-5 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-5 collide-with) (collide-kind target))
(set! (-> s3-5 prim-core offense) (collide-offense normal-attack))
(set! (-> s3-5 transform-index) 5)
(set-vector! (-> s3-5 local-sphere) 0.0 -2048.0 0.0 3276.8)
(append-prim s4-0 s3-5)))
(set! (-> s5-0 nav-radius) 9011.2)
(backup-collide-with-as s5-0)
(set! (-> this collide-info) s5-0))
(clear-collide-with-as (-> this collide-info))
(none))
(defmethod nav-enemy-method-48 ((this double-lurker-top))
(initialize-skeleton this *double-lurker-top-sg* '())
(set! (-> this draw origin-joint-index) (the-as uint 3))
(init-defaults! this *double-lurker-top-nav-enemy-info*)
(let ((v1-5 (-> this parent-process)))
(set! (-> this collide-info trans quad) (-> v1-5 0 collide-info trans quad))
(set-vector! (-> this collide-info scale) 1.0 1.0 1.0 1.0)
(quaternion-copy! (-> this collide-info quat) (-> v1-5 0 collide-info quat)))
(logclear! (-> this collide-info nav-flags) (nav-flags navf0))
(none))
(defbehavior double-lurker-top-init-by-other double-lurker-top ((arg0 entity) (arg1 double-lurker) (arg2 symbol) (arg3 vector))
(initialize-collision self)
(set! (-> self entity) (-> arg1 entity))
(nav-enemy-method-48 self)
(set! (-> self collide-info trans quad) (-> arg3 quad))
(cond
(arg2
(ja-channel-set! 1)
(ja :group! double-lurker-top-both-idle-ja :num! min)
(transform-post)
(let ((v1-13 (-> self draw shadow-ctrl))) (logior! (-> v1-13 settings flags) (shadow-flags disable-draw)))
0
(go double-lurker-top-on-shoulders))
(else
(ja-channel-set! 1)
(ja :group! double-lurker-top-idle-ja :num! min)
(transform-post)
(move-to-ground (-> self collide-info) 40960.0 40960.0 #t (collide-kind background))
(nav-enemy-method-51 self)
(go double-lurker-top-resume)))
(none))
;; WARN: disable def twice: 80. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare.
;; WARN: disable def twice: 120. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare.
(defbehavior double-lurker-default-event-handler double-lurker ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
(local-vars (v0-0 object))
(case arg2
(('touch) (set-time! (-> self touch-time)) (touch-handler self arg0 arg3))
(('attack)
(when (= (-> arg0 type) target)
(nav-enemy-set-hit-from-direction arg0)
(cond
((-> self buddy-on-shoulders?)
(let ((s4-0 (new 'stack-no-clear 'vector)))
(vector-! s4-0 (target-pos 0) (-> self collide-info trans))
(cond
((and (>= (-> s4-0 y) 8192.0)
(>= 14563.556 (fabs (deg- (quaternion-y-angle (-> self collide-info quat)) (atan (-> s4-0 x) (-> s4-0 z))))))
(when (send-event arg0 'shove (-> arg3 param 0) (static-attack-info ((shove-up (meters 3)) (shove-back (meters 2)))))
(increment-success-for-hint (text-id sunken-double-lurker-hint))
(go double-lurker-buddy-was-hit)
(return #f)
v0-0))
(else
(when (and ((method-of-type touching-shapes-entry prims-touching-action?)
(the-as touching-shapes-entry (-> arg3 param 0))
(-> (the-as target arg0) control)
(collide-action solid)
(collide-action))
(send-event arg0 'shove (-> arg3 param 0) (static-attack-info ((shove-up (meters 3)) (shove-back (meters 2))))))
(level-hint-spawn (text-id sunken-double-lurker-hint) "sksp0127" (the-as entity #f) *entity-pool* (game-task none))
(go double-lurker-both-knocked-back)
(return #f)
v0-0)))))
(else (nav-enemy-set-hit-from-direction arg0) (attack-handler self arg0 arg3)))))))
(defstate double-lurker-show-anims (double-lurker)
:trans
(behavior ()
0)
:code
(behavior ()
0)
:post transform-post)
(defstate double-lurker-resume (double-lurker)
:code
(behavior ()
(cond
((not *target*) (go-virtual nav-enemy-idle))
((target-in-range? self (-> self nav-info notice-distance)) (go-virtual nav-enemy-chase))
((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))
(nonzero? (-> self draw))
(logtest? (-> self draw status) (draw-status was-drawn)))
(go-virtual nav-enemy-patrol)))
(go-virtual nav-enemy-idle)))
(defstate nav-enemy-idle (double-lurker)
:virtual #t
:event double-lurker-default-event-handler)
(defstate nav-enemy-patrol (double-lurker)
:virtual #t
:event double-lurker-default-event-handler
:code
(behavior ()
(ja-channel-push! 1 (seconds 0.2))
(ja :group! (-> self draw art-group data (-> self nav-info walk-anim)))
(ja :num-func num-func-identity :frame-num 0.0)
(let ((t9-1 (-> (method-of-type nav-enemy nav-enemy-patrol) code))) (if t9-1 ((the-as (function none) t9-1))))))
(defstate nav-enemy-notice (double-lurker)
:virtual #t
:event double-lurker-default-event-handler
:enter
(behavior ()
(start-hint-timer (text-id sunken-double-lurker-hint))
(let ((t9-1 (-> (method-of-type nav-enemy nav-enemy-notice) enter))) (if t9-1 (t9-1)))))
(defstate nav-enemy-chase (double-lurker)
:virtual #t
:event double-lurker-default-event-handler)
(defstate nav-enemy-stop-chase (double-lurker)
:virtual #t
:event double-lurker-default-event-handler)
(defstate nav-enemy-stare (double-lurker)
:virtual #t
:event double-lurker-default-event-handler)
(defstate nav-enemy-victory (double-lurker)
:virtual #t
:event double-lurker-default-event-handler)
(defstate nav-enemy-die (double-lurker)
:virtual #t
:enter
(behavior ()
(let ((v1-2 (-> self entity extra perm)))
(logior! (-> v1-2 status) (entity-perm-status user-set-from-cstage))
(set! (-> v1-2 user-int8 0) 1))
(set! (-> self dead?) #t)
(let ((t9-0 (-> (method-of-type nav-enemy nav-enemy-die) enter))) (if t9-0 (t9-0)))))
(defstate double-lurker-both-knocked-back (double-lurker)
:enter
(behavior ()
(set! (-> self knocked-back-speed) 40960.0))
:trans
(behavior ()
(local-vars (at-0 int))
(rlet ((vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf))
(init-vf0-vector)
(let* ((f0-3 (seek-with-smooth (-> self knocked-back-speed) 0.0 (* 49152.0 (seconds-per-frame)) 0.5 0.01))
(f30-0 (* f0-3 (seconds-per-frame))))
(set! (-> self knocked-back-speed) f0-3)
(vector-float*! (-> self collide-info transv) (-> self hit-from-dir) f0-3)
(when (< 0.0 f0-3)
(let ((v1-7 (-> self nav travel)))
(.lvf vf1 (&-> (-> self collide-info transv) quad))
(let ((f0-4 (seconds-per-frame))) (.mov at-0 f0-4))
(.mov vf2 at-0)
(.mov.vf vf1 vf0 :mask #b1000)
(.mul.x.vf vf1 vf1 vf2 :mask #b111)
(.svf (&-> v1-7 quad) vf1))
(let ((gp-0 #f))
(nav-control-method-28 (-> self nav) (the-as collide-kind -1))
(let ((a2-1 (new 'stack-no-clear 'check-vector-collision-with-nav-spheres-info)))
(if (>= (nav-control-method-23 (-> self nav) (-> self nav travel) a2-1) 0.0) (set! gp-0 #t)))
(when (not gp-0)
(let ((s5-0 (new 'stack 'clip-travel-vector-to-mesh-return-info)))
(nav-control-method-24 (-> self nav) (* 1.2 f30-0) s5-0)
(if (-> s5-0 found-boundary) (set! gp-0 #t))))
(when gp-0
(set! (-> self knocked-back-speed) 0.0)
(vector-reset! (-> self collide-info transv))))))
(+! (-> self collide-info transv y) -36864.0)
(integrate-for-enemy-with-move-to-ground! (-> self collide-info)
(-> self collide-info transv)
(collide-kind background)
8192.0
#t
(-> self nav-info hover-if-no-ground)
#f)
(nav-control-method-27 (-> self nav))))
:code
(behavior ()
(ja-channel-push! 1 (seconds 0.2))
(ja-no-eval :group! double-lurker-both-take-hit-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!)))
(go double-lurker-resume))
:post nav-enemy-simple-post)
(defmethod nav-enemy-method-52 ((this double-lurker) (arg0 vector))
(nav-control-method-28 (-> this nav) (the-as collide-kind -1))
(let ((a1-2 (new 'stack-no-clear 'vector)))
(vector-float*! a1-2 (-> this hit-from-dir) 22937.602)
(vector+! a1-2 a1-2 (-> this collide-info trans))
(nav-control-method-13 (-> this nav) a1-2 (-> this hit-from-dir)))
(when (>= (vector-xz-length (-> this nav travel)) 18841.602)
(vector+! arg0 (-> this collide-info trans) (-> this nav travel))
(let ((a1-5 (new 'stack-no-clear 'vector))
(s4-0 (new 'stack-no-clear 'collide-tri-result)))
(set! (-> a1-5 quad) (-> arg0 quad))
(+! (-> a1-5 y) 8192.0)
(when (>= (fill-and-probe-using-line-sphere *collide-cache*
a1-5
(new 'static 'vector :y -40960.0 :w 1.0)
40.96
(collide-kind background)
this
s4-0
(new 'static 'pat-surface :noentity #x1))
0.0)
(set! (-> arg0 y) (-> s4-0 intersect y))
(return #t))))
#f)
(defstate double-lurker-buddy-was-hit (double-lurker)
:code
(behavior ()
(set! (-> self buddy-on-shoulders?) #f)
(let ((v1-2 (-> self entity extra perm)))
(logior! (-> v1-2 status) (entity-perm-status user-set-from-cstage))
(set! (-> v1-2 user-int8 2) 1))
(let ((gp-0 (new 'stack-no-clear 'vector)))
(if (nav-enemy-method-52 self gp-0)
(send-event (handle->process (-> self buddy-handle)) 'trigger gp-0)
(send-event (handle->process (-> self buddy-handle)) 'instant-death (-> self hit-from-dir))))
(nav-enemy-method-51 self)
(init-jm! self *double-lurker-nav-enemy-info*)
(go double-lurker-break-apart)))
(defstate double-lurker-break-apart (double-lurker)
:event double-lurker-default-event-handler
:code
(behavior ()
(ja-no-eval :group! double-lurker-both-break-apart-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!)))
(go double-lurker-resume))
:post nav-enemy-simple-post)
(defstate double-lurker-knocked-back (double-lurker)
:enter
(behavior ()
(set! (-> self knocked-back-speed) 40960.0))
:trans
(behavior ()
(local-vars (at-0 int))
(rlet ((vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf))
(init-vf0-vector)
(let* ((f0-3 (seek-with-smooth (-> self knocked-back-speed) 0.0 (* 49152.0 (seconds-per-frame)) 0.5 0.01))
(f30-0 (* f0-3 (seconds-per-frame))))
(set! (-> self knocked-back-speed) f0-3)
(vector-float*! (-> self collide-info transv) (-> self hit-from-dir) f0-3)
(when (< 0.0 f0-3)
(let ((v1-7 (-> self nav travel)))
(.lvf vf1 (&-> (-> self collide-info transv) quad))
(let ((f0-4 (seconds-per-frame))) (.mov at-0 f0-4))
(.mov vf2 at-0)
(.mov.vf vf1 vf0 :mask #b1000)
(.mul.x.vf vf1 vf1 vf2 :mask #b111)
(.svf (&-> v1-7 quad) vf1))
(let ((gp-0 #f))
(nav-control-method-28 (-> self nav) (the-as collide-kind -1))
(let ((a2-1 (new 'stack-no-clear 'check-vector-collision-with-nav-spheres-info)))
(if (>= (nav-control-method-23 (-> self nav) (-> self nav travel) a2-1) 0.0) (set! gp-0 #t)))
(when (not gp-0)
(let ((s5-0 (new 'stack 'clip-travel-vector-to-mesh-return-info)))
(nav-control-method-24 (-> self nav) (* 1.2 f30-0) s5-0)
(if (-> s5-0 found-boundary) (set! gp-0 #t))))
(when gp-0
(set! (-> self knocked-back-speed) 0.0)
(vector-reset! (-> self collide-info transv))))))
(+! (-> self collide-info transv y) -36864.0)
(integrate-for-enemy-with-move-to-ground! (-> self collide-info)
(-> self collide-info transv)
(collide-kind background)
8192.0
#t
(-> self nav-info hover-if-no-ground)
#f)
(nav-control-method-27 (-> self nav))))
:code
(behavior ()
(ja-channel-push! 1 (seconds 0.2))
(ja-no-eval :group! double-lurker-bottom-take-hit-ja :num! (seek!) :frame-num 0.0)
(until (ja-done? 0)
(suspend)
(ja :num! (seek!)))
(go double-lurker-resume))
:post nav-enemy-simple-post)
(defstate double-lurker-waiting-to-die (double-lurker)
:code
(behavior ()
(clear-collide-with-as (-> self collide-info))
(logior! (-> self draw status) (draw-status hidden))
(until (not (-> self child))
(suspend))))
(defmethod double-lurker-method-53 ((this double-lurker) (arg0 vector))
(let* ((s3-0 (-> this path curve num-cverts))
(s4-0 (rand-vu-int-count s3-0)))
(while (nonzero? s3-0)
(+! s3-0 -1)
(eval-path-curve-div! (-> this path) arg0 (the float s4-0) 'interp)
(if (not (nav-enemy-method-50 this arg0)) (return #t))))
#f)
(defmethod initialize-collision ((this double-lurker))
(let ((s5-0 (new 'process 'collide-shape-moving this (collide-list-enum hit-by-player))))
(set! (-> s5-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> s5-0 reaction) default-collision-reaction)
(set! (-> s5-0 no-reaction) (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing))
(let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 9) 0)))
(set! (-> s4-0 prim-core collide-as) (collide-kind enemy))
(set! (-> s4-0 collide-with) (collide-kind target))
(set! (-> s4-0 prim-core action) (collide-action solid))
(set-vector! (-> s4-0 local-sphere) 0.0 12288.0 0.0 18432.0)
(set-root-prim! s5-0 s4-0)
(let ((s3-0 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
(set! (-> s3-0 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-0 collide-with) (collide-kind target))
(set! (-> s3-0 prim-core action) (collide-action solid))
(set! (-> s3-0 prim-core offense) (collide-offense indestructible))
(set-vector! (-> s3-0 local-sphere) 0.0 15564.8 0.0 3686.4)
(append-prim s4-0 s3-0))
(let ((s3-1 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
(set! (-> s3-1 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-1 collide-with) (collide-kind target))
(set! (-> s3-1 prim-core action) (collide-action solid))
(set! (-> s3-1 prim-core offense) (collide-offense indestructible))
(set-vector! (-> s3-1 local-sphere) 0.0 19660.8 0.0 3686.4)
(append-prim s4-0 s3-1))
(let ((s3-2 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
(set! (-> s3-2 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-2 collide-with) (collide-kind target))
(set! (-> s3-2 prim-core offense) (collide-offense no-offense))
(set! (-> s3-2 transform-index) 5)
(set-vector! (-> s3-2 local-sphere) 0.0 8192.0 -1024.0 3276.8)
(append-prim s4-0 s3-2))
(let ((s3-3 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
(set! (-> s3-3 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-3 collide-with) (collide-kind target))
(set! (-> s3-3 prim-core action) (collide-action solid))
(set! (-> s3-3 prim-core offense) (collide-offense indestructible))
(set-vector! (-> s3-3 local-sphere) 0.0 3276.8 0.0 3686.4)
(append-prim s4-0 s3-3))
(let ((s3-4 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
(set! (-> s3-4 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-4 collide-with) (collide-kind target))
(set! (-> s3-4 prim-core action) (collide-action solid))
(set! (-> s3-4 prim-core offense) (collide-offense indestructible))
(set-vector! (-> s3-4 local-sphere) 0.0 7372.8 0.0 3686.4)
(append-prim s4-0 s3-4))
(let ((s3-5 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 2))))
(set! (-> s3-5 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-5 collide-with) (collide-kind target))
(set! (-> s3-5 prim-core action) (collide-action solid))
(set! (-> s3-5 prim-core offense) (collide-offense indestructible))
(set-vector! (-> s3-5 local-sphere) 0.0 11468.8 0.0 3686.4)
(append-prim s4-0 s3-5))
(let ((s3-6 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
(set! (-> s3-6 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-6 collide-with) (collide-kind target))
(set! (-> s3-6 prim-core offense) (collide-offense normal-attack))
(set! (-> s3-6 transform-index) 5)
(set-vector! (-> s3-6 local-sphere) 0.0 -2048.0 -2048.0 3686.4)
(append-prim s4-0 s3-6))
(let ((s3-7 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
(set! (-> s3-7 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-7 collide-with) (collide-kind target))
(set! (-> s3-7 prim-core offense) (collide-offense normal-attack))
(set! (-> s3-7 transform-index) 10)
(set-vector! (-> s3-7 local-sphere) 0.0 1024.0 0.0 1638.4)
(append-prim s4-0 s3-7))
(let ((s3-8 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 1))))
(set! (-> s3-8 prim-core collide-as) (collide-kind enemy))
(set! (-> s3-8 collide-with) (collide-kind target))
(set! (-> s3-8 prim-core offense) (collide-offense normal-attack))
(set! (-> s3-8 transform-index) 16)
(set-vector! (-> s3-8 local-sphere) 0.0 -1024.0 0.0 1638.4)
(append-prim s4-0 s3-8)))
(set! (-> s5-0 nav-radius) 9830.4)
(backup-collide-with-as s5-0)
(set! (-> this collide-info) s5-0)
s5-0))
(defmethod nav-enemy-method-51 ((this double-lurker))
(let ((v1-1 (-> this collide-info root-prim)))
(let ((a0-1 0))
(dotimes (a1-0 3)
(let ((a2-2 (-> (the-as collide-shape-prim-group v1-1) prims a0-1)))
(set! (-> a2-2 collide-with) (collide-kind))
(set! (-> a2-2 prim-core collide-as) (collide-kind))
(set! (-> a2-2 prim-core action) (collide-action))
(set! (-> a2-2 prim-core offense) (collide-offense no-offense)))
0
(+! a0-1 1)))
(countdown (a0-4 (-> (the-as collide-shape-prim-group v1-1) num-prims))
(let ((a1-3 (-> (the-as collide-shape-prim-group v1-1) prims a0-4)))
(if (and (= (-> a1-3 prim-core offense) (collide-offense indestructible)) (logtest? (-> a1-3 prim-id) 2))
(set! (-> a1-3 prim-core offense) (collide-offense touch))))))
(none))
(defmethod nav-enemy-method-48 ((this double-lurker))
(set! (-> this buddy-handle) (the-as handle #f))
(process-drawable-from-entity! this (-> this entity))
(set! (-> this align) (new 'process 'align-control this))
(initialize-skeleton this *double-lurker-sg* '())
(set! (-> this draw origin-joint-index) (the-as uint 3))
(set! (-> this buddy-on-shoulders?) #t)
(set! (-> this dead?) #f)
(set! (-> this buddy-dead?) #f)
(let ((v1-7 (-> this entity extra perm)))
(if (nonzero? (-> v1-7 user-int8 2)) (set! (-> this buddy-on-shoulders?) #f))
(when (nonzero? (-> v1-7 user-int8 0))
(set! (-> this dead?) #t)
(set! (-> this buddy-on-shoulders?) #f))
(when (nonzero? (-> v1-7 user-int8 1))
(set! (-> this buddy-dead?) #t)
(set! (-> this buddy-on-shoulders?) #f)))
(init-defaults! this *double-lurker-when-both-nav-enemy-info*)
(set! (-> this neck up) (the-as uint 1))
(set! (-> this neck nose) (the-as uint 2))
(set! (-> this neck ear) (the-as uint 0))
(set-vector! (-> this neck twist-max) 12743.111 12743.111 0.0 1.0)
(when (not (-> this buddy-dead?))
(let ((s5-0 (new 'stack-no-clear 'vector)))
(when (not (-> this buddy-on-shoulders?))
(when (not (double-lurker-method-53 this s5-0))
(set! (-> this buddy-on-shoulders?) #t)
(let ((v1-29 (-> this entity extra perm)))
(logior! (-> v1-29 status) (entity-perm-status user-set-from-cstage))
(set! (-> v1-29 user-int8 2) 0))
0))
(if (-> this buddy-on-shoulders?) (set! (-> s5-0 quad) (-> this collide-info trans quad)))
(set! (-> this buddy-handle)
(ppointer->handle (process-spawn double-lurker-top (-> this entity) this (-> this buddy-on-shoulders?) s5-0 :to this)))))
(when (and (not (-> this dead?)) (not (-> this buddy-on-shoulders?)))
(nav-enemy-method-51 this)
(init-jm! this *double-lurker-nav-enemy-info*))
(none))
(defmethod init-from-entity! ((this double-lurker) (arg0 entity-actor))
(initialize-collision this)
(nav-enemy-method-48 this)
(if (-> this dead?) (go double-lurker-waiting-to-die) (go (method-of-object this nav-enemy-idle)))
(none))