mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-21 17:47:44 -04:00
66e395d547
* detect `seek!` and `seekl!` * fancy struct instead of pair mess * fixes * i think this was wrong? * update refs * update source * More logical branching * even better branching
713 lines
25 KiB
Common Lisp
713 lines
25 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: swamp-bat.gc
|
|
;; name in dgo: swamp-bat
|
|
;; dgos: L1, SWA
|
|
|
|
(declare-type swamp-bat-slave process-drawable)
|
|
(declare-type swamp-bat process-drawable)
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype swamp-bat-idle-path (structure)
|
|
((origin vector :inline :offset-assert 0)
|
|
(x-axis vector :inline :offset-assert 16)
|
|
(y-axis vector :inline :offset-assert 32)
|
|
)
|
|
:method-count-assert 10
|
|
:size-assert #x30
|
|
:flag-assert #xa00000030
|
|
(:methods
|
|
(TODO-RENAME-9 (_type_ vector float) vector 9)
|
|
)
|
|
)
|
|
|
|
|
|
(defmethod TODO-RENAME-9 swamp-bat-idle-path ((obj swamp-bat-idle-path) (arg0 vector) (arg1 float))
|
|
(let ((f30-0 (* 65536.0 arg1)))
|
|
(set! (-> arg0 quad) (-> obj origin quad))
|
|
(vector+*! arg0 arg0 (-> obj x-axis) (cos f30-0))
|
|
(vector+*! arg0 arg0 (-> obj y-axis) (sin f30-0))
|
|
)
|
|
arg0
|
|
)
|
|
|
|
(deftype swamp-bat (process-drawable)
|
|
((child-process (pointer swamp-bat-slave) :offset 20)
|
|
(root-override collide-shape :offset 112)
|
|
(fact-override fact-info-enemy :offset 144)
|
|
(path-origin vector :inline :offset-assert 176)
|
|
(idle-position-angle float 8 :offset-assert 192)
|
|
(path-select-plane plane 2 :inline :offset-assert 224)
|
|
(path-list curve-control 2 :offset-assert 256)
|
|
(path-select int8 :offset-assert 264)
|
|
(slave-count int8 :offset-assert 265)
|
|
(path-count int8 :offset-assert 266)
|
|
)
|
|
:heap-base #xa0
|
|
:method-count-assert 20
|
|
:size-assert #x10b
|
|
:flag-assert #x1400a0010b
|
|
(:states
|
|
swamp-bat-idle
|
|
swamp-bat-launch-slaves
|
|
)
|
|
)
|
|
|
|
|
|
(defmethod relocate swamp-bat ((obj swamp-bat) (arg0 int))
|
|
(dotimes (v1-0 2)
|
|
(if (nonzero? (-> obj path-list v1-0))
|
|
(&+! (-> obj path-list v1-0) arg0)
|
|
)
|
|
)
|
|
(the-as
|
|
swamp-bat
|
|
((the-as (function process-drawable int process-drawable) (find-parent-method swamp-bat 7)) obj arg0)
|
|
)
|
|
)
|
|
|
|
(deftype swamp-bat-slave (process-drawable)
|
|
((parent-process (pointer swamp-bat) :offset 12)
|
|
(root-override collide-shape-moving :offset 112)
|
|
(sync sync-info :inline :offset-assert 176)
|
|
(idle-anim-speed float :offset-assert 184)
|
|
(strafe-envelope float :offset-assert 188)
|
|
(strafe-distance float :offset-assert 192)
|
|
(path-point-count float :offset-assert 196)
|
|
(idle-path swamp-bat-idle-path :inline :offset-assert 208)
|
|
(idle-position vector :inline :offset-assert 256)
|
|
(idle-position-index int8 :offset-assert 272)
|
|
(path-select int8 :offset-assert 273)
|
|
(launch-ready symbol :offset-assert 276)
|
|
)
|
|
:heap-base #xb0
|
|
:method-count-assert 21
|
|
:size-assert #x118
|
|
:flag-assert #x1500b00118
|
|
(:methods
|
|
(dummy-20 (_type_) float 20)
|
|
)
|
|
(:states
|
|
(swamp-bat-slave-die handle)
|
|
swamp-bat-slave-idle
|
|
swamp-bat-slave-launch
|
|
swamp-bat-slave-return
|
|
swamp-bat-slave-strafe
|
|
swamp-bat-slave-swoop
|
|
)
|
|
)
|
|
|
|
|
|
(defbehavior swamp-bat-slave-event-handler swamp-bat-slave ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
|
|
(case arg2
|
|
(('attack)
|
|
(logclear! (-> self mask) (process-mask actor-pause))
|
|
(go swamp-bat-slave-die (process->handle arg0))
|
|
)
|
|
(('touch)
|
|
(level-hint-spawn (game-text-id swamp-bats-hint) "sksp0156" (the-as entity #f) *entity-pool* (game-task none))
|
|
(send-event arg0 'attack (-> arg3 param 0) (new 'static 'attack-info))
|
|
)
|
|
(('launch)
|
|
(if (-> self launch-ready)
|
|
(go swamp-bat-slave-launch)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
swamp-bat-slave-event-handler
|
|
|
|
(defbehavior swamp-bat-slave-post swamp-bat-slave ()
|
|
(transform-post)
|
|
)
|
|
|
|
(defmethod dummy-20 swamp-bat-slave ((obj swamp-bat-slave))
|
|
(* (get-current-phase (-> obj sync)) (-> obj path-point-count))
|
|
)
|
|
|
|
(defbehavior swamp-bat-slave-path-post swamp-bat-slave ()
|
|
(let ((s2-0 (-> self parent-process 0 path-list (-> self path-select)))
|
|
(s5-0 (new-stack-vector0))
|
|
(gp-0 (new-stack-vector0))
|
|
(s4-0 (new-stack-vector0))
|
|
(f30-0 (dummy-20 self))
|
|
(s3-0 (new 'static 'vector :y 1.0 :w 1.0))
|
|
)
|
|
(eval-path-curve-div! s2-0 s5-0 f30-0 'interp)
|
|
(TODO-RENAME-12 s2-0 gp-0 f30-0)
|
|
(vector-cross! s4-0 gp-0 s3-0)
|
|
(vector-normalize! s4-0 1.0)
|
|
(let ((f0-4 (fmax
|
|
(fmin (- (vector-dot (target-pos 0) s4-0) (vector-dot s5-0 s4-0)) (-> self strafe-envelope))
|
|
(- (-> self strafe-envelope))
|
|
)
|
|
)
|
|
)
|
|
(seek! (-> self strafe-distance) f0-4 (* 20480.0 (-> *display* seconds-per-frame)))
|
|
)
|
|
(vector-float*! s4-0 s4-0 (-> self strafe-distance))
|
|
(vector+! (-> self root-override trans) s5-0 s4-0)
|
|
(forward-up->quaternion (-> self root-override quat) gp-0 s3-0)
|
|
)
|
|
(swamp-bat-slave-post)
|
|
)
|
|
|
|
(defskelgroup *swamp-bat-slave-sg* swamp-bat
|
|
0
|
|
4
|
|
((1 (meters 20)) (2 (meters 40)) (3 (meters 999999)))
|
|
:bounds (static-spherem 0 0 0 2.5)
|
|
:longest-edge (meters 0)
|
|
)
|
|
|
|
(defbehavior swamp-bat-slave-get-new-path swamp-bat-slave ()
|
|
(set! (-> self path-select) (-> self parent-process 0 path-select))
|
|
(set! (-> self idle-path origin quad) (-> self parent-process 0 path-origin quad))
|
|
(let* ((f28-0 (-> self parent-process 0 idle-position-angle (-> self idle-position-index)))
|
|
(f30-0 (cos f28-0))
|
|
(f26-0 (sin f28-0))
|
|
(f28-1 (cos 8192.0))
|
|
)
|
|
(let ((f0-0 (sin 8192.0)))
|
|
(set! (-> self idle-path x-axis x) (* 12288.0 f30-0))
|
|
(set! (-> self idle-path x-axis y) 0.0)
|
|
(set! (-> self idle-path x-axis z) (* 12288.0 f26-0))
|
|
(set! (-> self idle-path x-axis w) 1.0)
|
|
(set! (-> self idle-path y-axis x) (* -12288.0 f26-0 f28-1))
|
|
(set! (-> self idle-path y-axis y) (* 12288.0 f0-0))
|
|
)
|
|
(set! (-> self idle-path y-axis z) (* 12288.0 f30-0 f28-1))
|
|
)
|
|
(set! (-> self idle-path y-axis w) 1.0)
|
|
(vector+! (-> self idle-position) (the-as vector (-> self idle-path)) (-> self idle-path x-axis))
|
|
(let ((f0-8 (the float (+ (-> self parent-process 0 path-list (-> self path-select) curve num-cverts) -1))))
|
|
(set! (-> self path-point-count) f0-8)
|
|
f0-8
|
|
)
|
|
)
|
|
|
|
(defstate swamp-bat-slave-idle (swamp-bat-slave)
|
|
:event
|
|
swamp-bat-slave-event-handler
|
|
:code
|
|
(behavior ()
|
|
(set! (-> self state-time) (-> *display* base-frame-counter))
|
|
(set! (-> self launch-ready) #f)
|
|
(ja-channel-push! 1 49)
|
|
(let ((v1-4 (-> self skel root-channel 0)))
|
|
(set! (-> v1-4 frame-group) (the-as art-joint-anim (-> self draw art-group data 4)))
|
|
)
|
|
(let ((s5-0 (new 'stack-no-clear 'vector)))
|
|
(set! (-> s5-0 quad) (-> self root-override trans quad))
|
|
(let ((s4-0 (quaternion-copy! (new 'stack-no-clear 'quaternion) (-> self root-override quat)))
|
|
(gp-0 (new-stack-quaternion0))
|
|
)
|
|
(let ((s2-0
|
|
(TODO-RENAME-12 (-> self parent-process 0 path-list (-> self path-select)) (new 'stack-no-clear 'vector) 0.1)
|
|
)
|
|
)
|
|
0
|
|
(let* ((f0-0 300.0)
|
|
(f1-0 32768.0)
|
|
(s3-0 (the int (* f0-0 (/ 1.0 f1-0) (vector-vector-distance s5-0 (-> self idle-position)))))
|
|
)
|
|
(forward-up->quaternion gp-0 s2-0 (new 'static 'vector :y 1.0 :w 1.0))
|
|
(while #t
|
|
(let ((v1-17 (- (-> *display* base-frame-counter) (-> self state-time))))
|
|
(when (>= v1-17 s3-0)
|
|
0
|
|
(goto cfg-10)
|
|
)
|
|
(let ((f30-1 (/ (the float v1-17) (the float s3-0))))
|
|
(when *run-time-assert-enable*
|
|
(set-pos *__private-assert-info* "swamp-bat" (the-as uint 283) (the-as uint 20))
|
|
(__assert (< f30-1 1.0) "(< interp 1.0)")
|
|
)
|
|
(vector-lerp! (-> self root-override trans) s5-0 (-> self idle-position) f30-1)
|
|
(quaternion-slerp! (-> self root-override quat) s4-0 gp-0 f30-1)
|
|
)
|
|
)
|
|
(let ((a0-16 (-> self skel root-channel 0)))
|
|
(set! (-> a0-16 param 0) (-> self idle-anim-speed))
|
|
(joint-control-channel-group-eval! a0-16 (the-as art-joint-anim #f) num-func-loop!)
|
|
)
|
|
(suspend)
|
|
0
|
|
)
|
|
)
|
|
)
|
|
(label cfg-10)
|
|
(set! (-> self root-override trans quad) (-> self idle-position quad))
|
|
(quaternion-copy! (-> self root-override quat) gp-0)
|
|
)
|
|
)
|
|
(set! (-> self launch-ready) #t)
|
|
(logior! (-> self mask) (process-mask actor-pause))
|
|
(let ((f30-2 0.0))
|
|
(while #t
|
|
(let ((f26-0 (cos f30-2))
|
|
(f28-0 (sin f30-2))
|
|
)
|
|
(set! (-> self root-override trans quad) (-> self idle-path origin quad))
|
|
(vector+*! (-> self root-override trans) (-> self root-override trans) (-> self idle-path x-axis) f26-0)
|
|
(vector+*! (-> self root-override trans) (-> self root-override trans) (-> self idle-path y-axis) f28-0)
|
|
)
|
|
(let ((a0-26 (-> self skel root-channel 0)))
|
|
(set! (-> a0-26 param 0) (-> self idle-anim-speed))
|
|
(joint-control-channel-group-eval! a0-26 (the-as art-joint-anim #f) num-func-loop!)
|
|
)
|
|
(suspend)
|
|
(+! f30-2 (* 32768.0 (-> *display* seconds-per-frame) (-> self idle-anim-speed)))
|
|
)
|
|
)
|
|
(none)
|
|
)
|
|
:post
|
|
(the-as (function none :behavior swamp-bat-slave) swamp-bat-slave-post)
|
|
)
|
|
|
|
(defstate swamp-bat-slave-launch (swamp-bat-slave)
|
|
:event
|
|
swamp-bat-slave-event-handler
|
|
:code
|
|
(behavior ()
|
|
(set! (-> self state-time) (-> *display* base-frame-counter))
|
|
(set! (-> self launch-ready) #f)
|
|
(ja-channel-push! 1 30)
|
|
(let ((gp-0 (new-stack-vector0)))
|
|
(set! (-> gp-0 quad) (-> self root-override trans quad))
|
|
(let ((s5-0 (new-stack-vector0)))
|
|
(eval-path-curve-div! (-> self parent-process 0 path-list (-> self path-select)) s5-0 0.0 'interp)
|
|
(let ((v1-12 (-> self skel root-channel 0)))
|
|
(set! (-> v1-12 frame-group) (the-as art-joint-anim (-> self draw art-group data 4)))
|
|
)
|
|
(while #t
|
|
(let ((s4-0 (- (-> *display* base-frame-counter) (-> self state-time))))
|
|
(if (>= s4-0 (seconds 0.3))
|
|
(go swamp-bat-slave-swoop)
|
|
)
|
|
(let ((f0-1 (* 0.011111111 (the float s4-0))))
|
|
(vector-lerp! (-> self root-override trans) gp-0 s5-0 f0-1)
|
|
)
|
|
)
|
|
(let ((a0-9 (-> self skel root-channel 0)))
|
|
(set! (-> a0-9 param 0) (-> self idle-anim-speed))
|
|
(joint-control-channel-group-eval! a0-9 (the-as art-joint-anim #f) num-func-loop!)
|
|
)
|
|
(suspend)
|
|
0
|
|
)
|
|
)
|
|
)
|
|
(none)
|
|
)
|
|
:post
|
|
(the-as (function none :behavior swamp-bat-slave) swamp-bat-slave-post)
|
|
)
|
|
|
|
(defstate swamp-bat-slave-swoop (swamp-bat-slave)
|
|
:event
|
|
swamp-bat-slave-event-handler
|
|
:code
|
|
(behavior ()
|
|
(set! (-> self strafe-envelope) 0.0)
|
|
(ja-channel-push! 1 30)
|
|
(let ((gp-0 (-> self skel root-channel 0)))
|
|
(joint-control-channel-group-eval!
|
|
gp-0
|
|
(the-as art-joint-anim (-> self draw art-group data 5))
|
|
num-func-identity
|
|
)
|
|
(set! (-> gp-0 frame-num) 0.0)
|
|
)
|
|
(until (ja-done? 0)
|
|
(if (< (ja-aframe-num 0) 10.0)
|
|
(sync-now! (-> self sync) 0.0)
|
|
)
|
|
(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) 1.0)
|
|
(joint-control-channel-group-eval! a0-4 (the-as art-joint-anim #f) num-func-seek!)
|
|
)
|
|
)
|
|
(set! (-> self strafe-envelope) 20480.0)
|
|
(ja-channel-push! 1 30)
|
|
(let ((v1-18 (-> self skel root-channel 0)))
|
|
(set! (-> v1-18 frame-group) (the-as art-joint-anim (-> self draw art-group data 6)))
|
|
)
|
|
(while #t
|
|
(if (>= (dummy-20 self) 2.0)
|
|
(go swamp-bat-slave-strafe)
|
|
)
|
|
(let ((a0-11 (-> self skel root-channel 0)))
|
|
(set! (-> a0-11 param 0) 1.0)
|
|
(joint-control-channel-group-eval! a0-11 (the-as art-joint-anim #f) num-func-loop!)
|
|
)
|
|
(suspend)
|
|
)
|
|
(none)
|
|
)
|
|
:post
|
|
(the-as (function none :behavior swamp-bat-slave) swamp-bat-slave-path-post)
|
|
)
|
|
|
|
(defstate swamp-bat-slave-strafe (swamp-bat-slave)
|
|
:event
|
|
swamp-bat-slave-event-handler
|
|
:code
|
|
(behavior ()
|
|
(set! (-> self strafe-envelope) 20480.0)
|
|
(ja-channel-push! 1 30)
|
|
(let ((v1-2 (-> self skel root-channel 0)))
|
|
(set! (-> v1-2 frame-group) (the-as art-joint-anim (-> self draw art-group data 7)))
|
|
)
|
|
(while #t
|
|
(if (>= (dummy-20 self) 6.0)
|
|
(go swamp-bat-slave-return)
|
|
)
|
|
(let ((a0-5 (-> self skel root-channel 0)))
|
|
(set! (-> a0-5 param 0) 1.0)
|
|
(joint-control-channel-group-eval! a0-5 (the-as art-joint-anim #f) num-func-loop!)
|
|
)
|
|
(suspend)
|
|
)
|
|
(none)
|
|
)
|
|
:post
|
|
(the-as (function none :behavior swamp-bat-slave) swamp-bat-slave-path-post)
|
|
)
|
|
|
|
(defstate swamp-bat-slave-return (swamp-bat-slave)
|
|
:event
|
|
swamp-bat-slave-event-handler
|
|
:code
|
|
(behavior ()
|
|
(set! (-> self strafe-envelope) 0.0)
|
|
(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 7)))
|
|
)
|
|
(let ((f30-0 (+ -1.0 (-> self path-point-count)))
|
|
(gp-0 #t)
|
|
)
|
|
(while #t
|
|
(let ((f28-0 (dummy-20 self)))
|
|
(if (>= f28-0 f30-0)
|
|
(go swamp-bat-slave-idle)
|
|
)
|
|
(when (and gp-0 (>= f28-0 7.0) (< f28-0 8.0))
|
|
(set! gp-0 #f)
|
|
(when (!= (-> self path-select) (-> self parent-process 0 path-select))
|
|
(swamp-bat-slave-get-new-path)
|
|
(go swamp-bat-slave-idle)
|
|
)
|
|
)
|
|
)
|
|
(let ((a0-6 (-> self skel root-channel 0)))
|
|
(set! (-> a0-6 param 0) 1.0)
|
|
(joint-control-channel-group-eval! a0-6 (the-as art-joint-anim #f) num-func-loop!)
|
|
)
|
|
(suspend)
|
|
)
|
|
)
|
|
(none)
|
|
)
|
|
:post
|
|
(the-as (function none :behavior swamp-bat-slave) swamp-bat-slave-path-post)
|
|
)
|
|
|
|
(defstate swamp-bat-slave-die (swamp-bat-slave)
|
|
:event
|
|
(the-as
|
|
(function process int symbol event-message-block object :behavior swamp-bat-slave)
|
|
process-drawable-death-event-handler
|
|
)
|
|
:code
|
|
(behavior ((arg0 handle))
|
|
(ja-channel-push! 1 21)
|
|
(let ((gp-0 (new-stack-vector0)))
|
|
(let ((v1-1 (handle->process arg0)))
|
|
(if v1-1
|
|
(vector-! gp-0 (-> self root-override trans) (-> (the-as swamp-bat v1-1) root-override trans))
|
|
)
|
|
)
|
|
(set! (-> gp-0 y) (+ -6144.0 (-> gp-0 y)))
|
|
(vector-normalize! gp-0 98304.0)
|
|
(let ((v1-8 (-> self skel root-channel 0)))
|
|
(set! (-> v1-8 frame-group) (the-as art-joint-anim (-> self draw art-group data 8)))
|
|
)
|
|
(until (ja-done? 0)
|
|
(vector-v++! (-> self root-override trans) gp-0)
|
|
(let ((a0-12 (-> self skel root-channel 0)))
|
|
(set! (-> a0-12 param 0) (the float (+ (-> a0-12 frame-group data 0 length) -1)))
|
|
(set! (-> a0-12 param 1) 0.5)
|
|
(joint-control-channel-group-eval! a0-12 (the-as art-joint-anim #f) num-func-seek!)
|
|
)
|
|
(suspend)
|
|
)
|
|
)
|
|
(cleanup-for-death self)
|
|
(none)
|
|
)
|
|
:post
|
|
(the-as (function none :behavior swamp-bat-slave) swamp-bat-slave-post)
|
|
)
|
|
|
|
(defbehavior swamp-bat-slave-init-by-other swamp-bat-slave ((arg0 swamp-bat-slave) (arg1 int))
|
|
(set! (-> self mask) (logior (process-mask enemy) (-> self mask)))
|
|
(let ((s4-0 (new 'process 'collide-shape-moving self (collide-list-enum usually-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-group s4-0 (the-as uint 1) 0)))
|
|
(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-vector! (-> s3-0 local-sphere) 0.0 0.0 0.0 6144.0)
|
|
(set-root-prim! s4-0 s3-0)
|
|
(let ((s2-0 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
|
|
(set! (-> s2-0 prim-core collide-as) (collide-kind enemy))
|
|
(set! (-> s2-0 collide-with) (collide-kind target))
|
|
(set! (-> s2-0 prim-core action) (collide-action solid))
|
|
(set! (-> s2-0 prim-core offense) (collide-offense indestructible))
|
|
(set! (-> s2-0 transform-index) 3)
|
|
(set-vector! (-> s2-0 local-sphere) 0.0 0.0 0.0 4096.0)
|
|
(append-prim s3-0 s2-0)
|
|
)
|
|
)
|
|
(set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
|
|
(backup-collide-with-as s4-0)
|
|
(set! (-> self root-override) s4-0)
|
|
)
|
|
(set! (-> self root-override trans quad) (-> arg0 root-override trans quad))
|
|
(set! (-> self root-override quat vec quad) (-> arg0 root-override quat vec quad))
|
|
(vector-float*! (-> self root-override scale) *identity-vector* 2.0)
|
|
(set! (-> self root-override pause-adjust-distance) 286720.0)
|
|
(set! (-> self fact)
|
|
(new 'process 'fact-info-enemy self (pickup-type eco-pill-random) (-> *FACT-bank* default-pill-inc))
|
|
)
|
|
(set! (-> self idle-anim-speed) (rand-vu-float-range 0.9 1.1))
|
|
(set! (-> self strafe-distance) 0.0)
|
|
(set! (-> self strafe-envelope) 0.0)
|
|
(set! (-> self idle-position-index) arg1)
|
|
(swamp-bat-slave-get-new-path)
|
|
(set! (-> self root-override trans quad) (-> self idle-position quad))
|
|
(setup-params! (-> self sync) (the-as uint 1200) 0.0 0.15 0.15)
|
|
(initialize-skeleton self *swamp-bat-slave-sg* '())
|
|
(logclear! (-> self mask) (process-mask actor-pause))
|
|
(go swamp-bat-slave-idle)
|
|
(none)
|
|
)
|
|
|
|
(defbehavior swamp-bat-setup-new-path swamp-bat ((arg0 int))
|
|
(when *run-time-assert-enable*
|
|
(set-pos *__private-assert-info* "swamp-bat" (the-as uint 520) (the-as uint 2))
|
|
(__assert-zero-lim-range-int arg0 (-> self path-count) "path-index" "(-> self path-count)")
|
|
)
|
|
(when (< 0.0 (the float (+ (-> self path-list arg0 curve num-cverts) -1)))
|
|
(set! (-> self path-select) arg0)
|
|
(let ((f30-0 0.0)
|
|
(f28-0 (/ 65536.0 (the float (-> self slave-count))))
|
|
)
|
|
(eval-path-curve-div! (-> self path-list arg0) (-> self path-origin) 0.0 'interp)
|
|
(dotimes (v1-16 (-> self slave-count))
|
|
(set! (-> self idle-position-angle v1-16) f30-0)
|
|
(+! f30-0 f28-0)
|
|
)
|
|
)
|
|
#f
|
|
)
|
|
)
|
|
|
|
(defbehavior swamp-bat-make-path-select-plane swamp-bat ((arg0 int))
|
|
(when *run-time-assert-enable*
|
|
(set-pos *__private-assert-info* "swamp-bat" (the-as uint 538) (the-as uint 2))
|
|
(__assert-zero-lim-range-int arg0 (-> self path-count) "path-index" "(-> self path-count)")
|
|
)
|
|
(let* ((s5-0 (-> self path-list arg0))
|
|
(gp-1 (TODO-RENAME-12 s5-0 (-> self path-select-plane arg0) 5.0))
|
|
(s5-1 (eval-path-curve-div! s5-0 (new 'stack-no-clear 'vector) 5.0 'interp))
|
|
)
|
|
(set! (-> gp-1 y) 0.0)
|
|
(vector-normalize! gp-1 1.0)
|
|
(let ((f0-3 (- (vector-dot s5-1 gp-1))))
|
|
(set! (-> gp-1 w) f0-3)
|
|
f0-3
|
|
)
|
|
)
|
|
)
|
|
|
|
(defbehavior swamp-bat-update-path swamp-bat ()
|
|
(dotimes (gp-0 (-> self path-count))
|
|
(when (!= (-> self path-select) gp-0)
|
|
(let* ((s5-0 (-> self path-select-plane gp-0))
|
|
(f0-2 (+ (vector-dot (target-pos 0) (the-as vector s5-0)) (-> s5-0 w)))
|
|
)
|
|
(if (< 0.0 f0-2)
|
|
(swamp-bat-setup-new-path gp-0)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(none)
|
|
)
|
|
|
|
(defbehavior swamp-bat-debug swamp-bat ()
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defbehavior swamp-bat-check-slave-paths-match? swamp-bat ((arg0 int))
|
|
(let ((v1-0 (the-as (pointer process-tree) (-> self child-process))))
|
|
(while v1-0
|
|
(if (and (-> (the-as swamp-bat-slave (-> v1-0 0)) launch-ready)
|
|
(!= (-> (the-as swamp-bat-slave (-> v1-0 0)) path-select) arg0)
|
|
)
|
|
(return #f)
|
|
)
|
|
(set! v1-0 (-> v1-0 0 brother))
|
|
)
|
|
)
|
|
#t
|
|
)
|
|
|
|
(defstate swamp-bat-idle (swamp-bat)
|
|
:trans
|
|
swamp-bat-debug
|
|
:code
|
|
(behavior ()
|
|
(when (zero? (-> self path-count))
|
|
(process-entity-status! self (entity-perm-status dead) #t)
|
|
(deactivate self)
|
|
)
|
|
(while #t
|
|
(when (and (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.2))
|
|
*target*
|
|
(>= (-> self fact-override idle-distance)
|
|
(vector-vector-distance (-> self root-override trans) (-> *target* control trans))
|
|
)
|
|
)
|
|
(when (not (-> self child-process))
|
|
(process-entity-status! self (entity-perm-status dead) #t)
|
|
(deactivate self)
|
|
)
|
|
(swamp-bat-update-path)
|
|
(if (or (dummy-10 (-> self vol) (target-pos 5)) (not (swamp-bat-check-slave-paths-match? (-> self path-select))))
|
|
(go swamp-bat-launch-slaves)
|
|
)
|
|
)
|
|
(let ((gp-1 (new 'static 'matrix)))
|
|
(quaternion->matrix gp-1 (-> self root-override quat))
|
|
(set! (-> gp-1 vector 3 quad) (-> self root-override trans quad))
|
|
)
|
|
(suspend)
|
|
)
|
|
(none)
|
|
)
|
|
:post
|
|
(the-as (function none :behavior swamp-bat) #f)
|
|
)
|
|
|
|
(defbehavior swamp-bat-launch-slave swamp-bat ()
|
|
(let ((gp-0 (the-as (pointer process-tree) (-> self child-process)))
|
|
(v0-0 (the-as object #f))
|
|
)
|
|
(while (and gp-0 (not v0-0))
|
|
(let ((a1-0 (new 'stack-no-clear 'event-message-block)))
|
|
(set! (-> a1-0 from) self)
|
|
(set! (-> a1-0 num-params) 0)
|
|
(set! (-> a1-0 message) 'launch)
|
|
(set! v0-0 (send-event-function (ppointer->process gp-0) a1-0))
|
|
)
|
|
(set! gp-0 (-> gp-0 0 brother))
|
|
)
|
|
v0-0
|
|
)
|
|
)
|
|
|
|
(defstate swamp-bat-launch-slaves (swamp-bat)
|
|
:trans
|
|
swamp-bat-debug
|
|
:code
|
|
(behavior ()
|
|
(set! (-> self state-time) (-> *display* base-frame-counter))
|
|
(while #t
|
|
(swamp-bat-update-path)
|
|
(when (>= (- (-> *display* base-frame-counter) (-> self state-time)) (seconds 0.5))
|
|
(set! (-> self state-time) (-> *display* base-frame-counter))
|
|
(if (not (swamp-bat-launch-slave))
|
|
(go swamp-bat-idle)
|
|
)
|
|
)
|
|
(suspend)
|
|
)
|
|
(none)
|
|
)
|
|
:post
|
|
(the-as (function none :behavior swamp-bat) #f)
|
|
)
|
|
|
|
(defmethod init-from-entity! swamp-bat ((obj swamp-bat) (arg0 entity-actor))
|
|
(let ((s4-0 (new 'process 'collide-shape obj (collide-list-enum hit-by-player))))
|
|
(let ((s3-0 (new 'process 'collide-shape-prim-sphere s4-0 (the-as uint 0))))
|
|
(set-vector! (-> s3-0 local-sphere) 0.0 0.0 0.0 0.0)
|
|
(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 root-override) s4-0)
|
|
)
|
|
(process-drawable-from-entity! obj arg0)
|
|
(logclear! (-> obj mask) (process-mask actor-pause))
|
|
(set! (-> obj mask) (logior (process-mask enemy) (-> obj mask)))
|
|
(set! (-> obj vol) (new 'process 'vol-control obj))
|
|
(logior! (-> obj vol flags) 3)
|
|
(set! (-> obj path-list 0) (new 'process 'curve-control obj 'path -1000000000.0))
|
|
(set! (-> obj path-list 1) (new 'process 'curve-control obj 'pathb -1000000000.0))
|
|
(logior! (-> obj path-list 0 flags) (path-control-flag display draw-line draw-point draw-text))
|
|
(logior! (-> obj path-list 1 flags) (path-control-flag display draw-line draw-point draw-text))
|
|
(set! (-> obj path-count) 0)
|
|
(when (< 0.0 (the float (+ (-> obj path-list 0 curve num-cverts) -1)))
|
|
(+! (-> obj path-count) 1)
|
|
(swamp-bat-make-path-select-plane 0)
|
|
)
|
|
(when (< 0.0 (the float (+ (-> obj path-list 1 curve num-cverts) -1)))
|
|
(+! (-> obj path-count) 1)
|
|
(swamp-bat-make-path-select-plane 1)
|
|
)
|
|
(if (!= (-> obj path-count) 2)
|
|
(go process-drawable-art-error "need 2 paths")
|
|
)
|
|
(set! (-> obj fact-override)
|
|
(new 'process 'fact-info-enemy obj (pickup-type eco-pill-random) (-> *FACT-bank* default-pill-inc))
|
|
)
|
|
(let ((a1-10 (res-lump-value arg0 'num-lurkers uint128 :default (the-as uint128 6))))
|
|
(set! (-> obj slave-count) (max 2 (min 8 (the-as int a1-10))))
|
|
)
|
|
(swamp-bat-setup-new-path 0)
|
|
(swamp-bat-update-path)
|
|
(dotimes (s5-1 (-> obj slave-count))
|
|
(let ((s4-1 (get-process *default-dead-pool* swamp-bat-slave 4512)))
|
|
(when s4-1
|
|
(let ((t9-16 (method-of-type swamp-bat-slave activate)))
|
|
(t9-16 (the-as swamp-bat-slave s4-1) obj 'swamp-bat-slave (the-as pointer #x70004000))
|
|
)
|
|
(run-now-in-process s4-1 swamp-bat-slave-init-by-other obj s5-1)
|
|
(-> s4-1 ppointer)
|
|
)
|
|
)
|
|
)
|
|
(go swamp-bat-idle)
|
|
(none)
|
|
)
|
|
|
|
|
|
|
|
|