jak-project/goal_src/jak3/levels/factory/fac-robotank.gc

899 lines
32 KiB
Common Lisp
Raw Normal View History

2023-10-10 09:41:05 -04:00
;;-*-Lisp-*-
(in-package goal)
;; name: fac-robotank.gc
;; name in dgo: fac-robotank
;; dgos: LFACTORY
;; +++robotank-segment-flag
(defenum robotank-segment-flag
:type uint16
:bitfield #t
)
;; ---robotank-segment-flag
;; +++robotank-flag
(defenum robotank-flag
:type uint16
:bitfield #t
(r0 0)
(r1 1)
(r2 2)
(r3 3)
(r4 4)
(r5 5)
(r6 6)
(r7 7)
)
;; ---robotank-flag
(declare-type fort-robotank process-drawable)
2023-10-10 09:41:05 -04:00
;; DECOMP BEGINS
(defpartgroup group-robotank-barrel-sparks
:id 783
:bounds (static-bspherem 0 0 0 8)
:parts ((sp-item 2927 :fade-after (meters 120) :falloff-to (meters 120) :flags (sp7)))
)
(defpart 2927
:init-specs ((:texture (motion-blur-part level-default-sprite))
(:num 1.0 6.0)
(:x (meters -4) (meters 8))
(:scale-x (meters 1))
(:rot-x 4)
(:scale-y (meters 0.05) (meters 0.05))
(:r 32.0 96.0)
(:g :copy r)
(:b 255.0)
(:a 64.0 64.0)
(:omega (degrees 0.03375))
(:vel-y (meters 0.016666668) (meters 0.033333335))
(:fade-r -0.85333335)
(:fade-g -0.85333335)
(:accel-y (meters -0.0026666666) (meters -0.001))
(:friction 0.875)
(:timer (seconds 0.085) (seconds 0.33))
(:flags (sp-cpuinfo-flag-0 sp-cpuinfo-flag-2 sp-cpuinfo-flag-3))
(:func 'sparticle-motion-blur)
(:next-time (seconds 0.017) (seconds 0.98))
(:next-launcher 2928)
(:conerot-x (degrees -45) (degrees 90))
(:conerot-y (degrees -45) (degrees 90))
(:conerot-z (degrees -45) (degrees 90))
(:rotate-y (degrees 0))
(:conerot-radius (meters 0) (meters 0.2))
)
)
(defpart 2928
:init-specs ((:fade-r 0.0) (:fade-g 0.0) (:fade-b 0.0) (:fade-a -0.85333335 -1.7066667))
)
(deftype fac-robotank-segment-event (structure)
((source uint64)
(event-type symbol)
(actor string)
(pos-norm float)
(param basic)
(param-obj object :overlay-at param)
(param-func (function fort-robotank none) :overlay-at param)
(param-sym symbol :overlay-at param)
)
)
(deftype fac-robotank-segment (structure)
((flags robotank-segment-flag)
(max-speed float)
(next-segment int32)
(next-segment-start float)
(event-count int32)
(event-tbl (inline-array fac-robotank-segment-event))
)
)
(deftype fac-robotank-path-info (structure)
((dir vector :inline)
(u float)
(du float)
(du-final float)
(prev-u float)
(max-speed float)
(dist float)
(dir-y-angle float)
(start-y-angle float)
)
)
(deftype fac-robotank-path-info-array (inline-array-class)
((data fac-robotank-path-info :inline :dynamic)
)
)
(set! (-> fac-robotank-path-info-array heap-base) (the-as uint 48))
(deftype fac-robotank-wheel-info (structure)
((jmod joint-mod-spinner)
(radius float)
)
)
(deftype fac-robotank-tread-info (structure)
((wheel fac-robotank-wheel-info 7 :inline)
(texture texture-anim)
(locator-joint int32)
(pos vector :inline)
)
)
(deftype fac-robotank (process-focusable)
((parent (pointer factory-manager) :override)
(self fac-robotank :override)
(ppointer (pointer fac-robotank) :override)
(barrel-part sparticle-launch-control)
(vibe-jmod joint-mod-blend-local :inline)
(tread fac-robotank-tread-info 2 :inline)
(path-info fac-robotank-path-info-array)
(flags robotank-flag)
(mgr handle)
(pov-cam-offset vector 2 :inline)
(explode-sg skeleton-group)
(turret handle)
(no-collision-timer time-frame)
(buzz-timer time-frame)
(engine-vibe-rate float)
(engine-vibe-amp float)
(attack-id uint32)
(path-index int32)
(path-count int32)
(continue-index int32)
(hit-points float)
(engine-sound sound-id)
(engine-sound-playing symbol)
(snd-cmd-time time-frame)
)
(:state-methods
turning
moving
pause
die
)
(:methods
(fac-robotank-method-32 (_type_) none)
(fac-robotank-method-33 (_type_) none)
(go-explode (_type_) (pointer joint-exploder))
)
)
(defskelgroup skel-fac-robotank fac-robotank fac-robotank-lod0-jg fac-robotank-idle-ja
((fac-robotank-lod0-mg (meters 20)) (fac-robotank-lod1-mg (meters 999999)))
:bounds (static-spherem 0 0 0 9)
:origin-joint-index 3
)
(defskelgroup skel-fac-robotank-explode fac-robotank fac-robotank-explode-lod0-jg fac-robotank-explode-idle-ja
((fac-robotank-explode-lod0-mg (meters 999999)))
:bounds (static-spherem 0 0 0 15)
)
(define *fac-robotank-exploder-params*
(new 'static 'joint-exploder-static-params
:joints (new 'static 'boxed-array :type joint-exploder-static-joint-params
(new 'static 'joint-exploder-static-joint-params :joint-index 3 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 4 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 5 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 6 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 7 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 8 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 9 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 10 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 11 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 12 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 13 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 14 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 15 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 16 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 17 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 18 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 19 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 20 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 21 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 22 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 23 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 24 :parent-joint-index -1)
(new 'static 'joint-exploder-static-joint-params :joint-index 25 :parent-joint-index -1)
)
:collide-spec (collide-spec backgnd)
)
)
;; WARN: Return type mismatch event-message-block vs none.
(defmethod fac-robotank-method-32 ((this fac-robotank))
(with-pp
(let ((v1-0 (-> this root)))
(when (< (-> *event-queue* length) (-> *event-queue* allocated-length))
(let ((v0-1 (-> *event-queue* data (-> *event-queue* length))))
(+! (-> *event-queue* length) 1)
(set! (-> v0-1 from-handle) (process->handle pp))
(set! (-> v0-1 to-handle) (process->handle (handle->process (-> this turret))))
(set! (-> v0-1 num-params) 4)
(set! (-> v0-1 message) 'update)
(set! (-> v0-1 param 0) (the-as uint (-> v1-0 trans)))
(set! (-> v0-1 param 1) (the-as uint (-> v1-0 quat)))
(set! (-> v0-1 param 2) (the-as uint (-> this node-list data 3)))
(set! (-> v0-1 param 3) (the-as uint (-> this vibe-jmod transform quat)))
)
)
)
(none)
)
)
(defbehavior fac-robotank-post fac-robotank ()
(when (and (nonzero? (-> self no-collision-timer))
(time-elapsed? (-> self no-collision-timer) (-> *TARGET-bank* hit-invulnerable-timeout))
)
(let ((v1-7 (-> self root root-prim)))
(set! (-> v1-7 prim-core collide-as) (-> self root backup-collide-as))
(set! (-> v1-7 prim-core collide-with) (-> self root backup-collide-with))
)
(set! (-> self no-collision-timer) 0)
0
)
(fac-robotank-method-32 self)
(dotimes (gp-0 2)
(let* ((s5-0 (-> self tread gp-0))
(s4-0 (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data (-> s5-0 locator-joint))))
)
(let ((s3-1 (vector-! (new 'stack-no-clear 'vector) s4-0 (-> s5-0 pos))))
(let ((s2-0 (vector-x-quaternion! (new 'stack-no-clear 'vector) (-> self root quat))))
(if (= gp-0 1)
(vector-float*! s2-0 s2-0 -1.0)
)
(let ((s1-0 (get-field-spec-by-id (-> *part-id-table* 2924) (sp-field-id spt-num)))
(f30-0 (vector-length s3-1))
(f28-0 (* 12288.0 (seconds-per-frame)))
)
(set! (-> s1-0 initial-valuef) (lerp-scale 0.0 0.5 f30-0 0.0 f28-0))
(set! (-> s1-0 random-rangef) (lerp-scale 0.0 1.0 f30-0 0.0 f28-0))
)
(let ((a1-8 (forward-up-nopitch->inv-matrix (new 'stack-no-clear 'matrix) s2-0 *up-vector*)))
(set! (-> a1-8 trans quad) (-> s4-0 quad))
(+! (-> a1-8 trans y) -2498.56)
(spawn-from-mat (-> self part) a1-8)
)
)
(vector-inv-orient-by-quat! s3-1 s3-1 (-> self root quat))
(let ((f30-1 (fabs (-> s3-1 z))))
(dotimes (s3-2 7)
(let ((s2-1 (-> s5-0 wheel s3-2)))
(set! (-> s2-1 jmod spin-rate) (* (atan f30-1 (-> s2-1 radius)) (-> self clock frames-per-second)))
)
)
)
)
(set! (-> s5-0 pos quad) (-> s4-0 quad))
)
)
(let ((v1-48 (-> self path-info data (-> self path-index))))
(cond
((and (logtest? (-> self flags) (robotank-flag r2)) (!= (-> v1-48 u) (-> v1-48 prev-u)))
(seek! (-> self engine-vibe-rate) 3.0 (seconds-per-frame))
(seek! (-> self engine-vibe-amp) 1.0 (seconds-per-frame))
)
(else
(seek! (-> self engine-vibe-rate) 1.0 (seconds-per-frame))
(seek! (-> self engine-vibe-amp) 0.4 (seconds-per-frame))
)
)
)
(let* ((f0-23 30.0)
(f1-4 65536.0)
(f2-1 (the float (current-time)))
(f0-24 (/ (* f1-4 (- f2-1 (* (the float (the int (/ f2-1 f0-23))) f0-23))) f0-23))
(f30-2 (sin f0-24))
(f28-1 (* 300.0 (/ 1.0 (-> self engine-vibe-rate))))
(f0-27 (the float (current-time)))
(f26-0 (/ (- f0-27 (* (the float (the int (/ f0-27 f28-1))) f28-1)) f28-1))
(f30-3 (* f30-2 (sin (* 65536.0 f26-0))))
)
(let* ((f0-32 (sin 7281.778))
(f1-13 (- 1.0 f0-32))
)
0.0
(when (and (or (< f0-32 f26-0) (< f26-0 f1-13)) (time-elapsed? (-> self buzz-timer) (the int (* 0.5 f28-1))))
(let* ((gp-1 *target*)
(a0-37 (if (type? gp-1 process-focusable)
gp-1
)
)
)
(if a0-37
(lerp-scale 1.0 0.0 (vector-vector-distance (-> self root trans) (get-trans a0-37 0)) 81920.0 327680.0)
)
)
(set-time! (-> self buzz-timer))
)
)
(quaternion-axis-angle!
(-> self vibe-jmod transform quat)
0.0
0.0
1.0
(* 182.04445 (* (-> self engine-vibe-amp) f30-3))
)
)
(when (logtest? (-> self flags) (robotank-flag r7))
(let ((gp-3 (quaternion-inverse! (new 'stack-no-clear 'quaternion) (-> self root quat)))
(a1-21 (new 'stack-no-clear 'event-message-block))
)
(set! (-> a1-21 from) (process->ppointer self))
(set! (-> a1-21 num-params) 0)
(set! (-> a1-21 message) 'get-rotate-quat)
(let ((s5-2 (send-event-function (handle->process (-> self turret)) a1-21))
(s4-2 (new 'stack-no-clear 'quaternion))
(s2-3 (-> (the-as fac-robotank-turret (handle->process (-> self turret))) root trans))
(s1-1 (-> self root trans))
(s3-4 (new 'stack-no-clear 'vector))
)
(let ((a1-23 (new 'stack-no-clear 'event-message-block)))
(set! (-> a1-23 from) (process->ppointer self))
(set! (-> a1-23 num-params) 0)
(set! (-> a1-23 message) 'get-gun-elevation-cam)
(let ((f30-4 (the-as float (send-event-function (handle->process (-> self turret)) a1-23))))
(vector-! s3-4 s2-3 s1-1)
(vector-orient-by-quat! s3-4 s3-4 gp-3)
(quaternion*! s4-2 (the-as quaternion s5-2) gp-3)
(quaternion-normalize! s4-2)
(quaternion-rotate-local-x! s4-2 s4-2 f30-4)
)
)
(vector-orient-by-quat! (the-as vector (-> self pov-cam-offset)) (-> self pov-cam-offset 1) s4-2)
(vector+! (the-as vector (-> self pov-cam-offset)) (the-as vector (-> self pov-cam-offset)) s3-4)
)
)
)
(pusher-post)
(none)
)
(defbehavior fac-robotank-handler fac-robotank ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
(case arg2
(('trigger)
(when (and *target* (< (-> self continue-index) (the-as int (-> arg3 param 0))))
(if (< (-> self continue-index) 0)
(add-process *gui-control* self (gui-channel alert) (gui-action play) "cityv107" -99.0 0)
)
(logior! (-> self flags) (robotank-flag r5))
(let ((v0-0 (the-as object (-> arg3 param 0))))
(set! (-> self continue-index) (the-as int v0-0))
v0-0
)
)
)
(('trans)
(-> self root trans)
)
(('die)
(go-virtual die)
)
(('fire-suppress-on)
(send-event (handle->process (-> self turret)) 'fire-suppress #t)
)
(('fire-suppress-off)
(send-event (handle->process (-> self turret)) 'fire-suppress #f)
)
(('attack)
(let ((v1-26 (the-as attack-info (-> arg3 param 1))))
0.0
(let ((f1-0 (if (logtest? (attack-mask damage) (-> v1-26 mask))
(-> v1-26 damage)
0.0
)
)
)
(set! (-> self hit-points) (fmax 0.0 (- (-> self hit-points) f1-0)))
)
)
(when (>= 0.0 (-> self hit-points))
(go-explode self)
(go-virtual die)
)
)
(('stop-music)
(remove-setting! 'music)
(remove-setting! 'music-volume)
(remove-setting! 'sound-mode)
)
)
)
(defstate turning (fac-robotank)
:virtual #t
:event fac-robotank-handler
:enter (behavior ()
(set! (-> self path-info data (-> self path-index) start-y-angle) (quaternion-y-angle (-> self root quat)))
)
:trans (behavior ()
(let* ((gp-0 (-> self path-info data (-> self path-index)))
(s5-0 (-> self root))
(f30-0 (quaternion-y-angle (-> s5-0 quat)))
(f28-0 (fabs (deg-diff f30-0 (-> gp-0 start-y-angle))))
(f30-1 (fabs (deg-diff f30-0 (vector-y-angle (-> gp-0 dir)))))
)
(let* ((f0-3 (fmin f28-0 f30-1))
(f0-6 (fmax 728.1778 (fmin 10012.444 (* 4.0 f0-3))))
)
(seek-toward-heading-vec! s5-0 (-> gp-0 dir) f0-6 (seconds 0.02))
)
(if (< f30-1 36.40889)
(go-virtual pause)
)
)
)
:code sleep-code
:post (behavior ()
(fac-robotank-post)
)
)
(defmethod get-trans ((this fac-robotank) (arg0 int))
"Get the `trans` for this process."
(-> this root trans)
)
(defstate moving (fac-robotank)
:virtual #t
:event fac-robotank-handler
:enter (behavior ()
(let ((v1-3 (-> self path-info data (-> self path-index))))
(set! (-> v1-3 u) 0.0)
(set! (-> v1-3 prev-u) -1.0)
(set! (-> v1-3 du) 0.0)
(set! (-> v1-3 du-final) 0.01)
)
(sound-play "tank-engine" :id (-> self engine-sound) :position (-> self root trans))
(set! (-> self engine-sound-playing) #t)
(set-time! (-> self snd-cmd-time))
)
:exit (behavior ()
(logclear! (-> self flags) (robotank-flag r2))
)
:trans (behavior ()
(if (not *target*)
(go-virtual die)
)
(let* ((gp-0 *target*)
(a0-1 (if (type? gp-0 process-focusable)
gp-0
)
)
)
(when a0-1
(if (< (-> (get-trans a0-1 0) y) (+ -18432.0 (-> self root trans y)))
(go-virtual die)
)
)
)
(let ((v1-14 (-> self path-index)))
(when (= (-> self path-info data v1-14 u) 1.0)
)
)
)
:code (behavior ()
(logclear! (-> self flags) (robotank-flag r2))
(let ((gp-0 (current-time)))
(until (time-elapsed? gp-0 (seconds 0.1))
(suspend)
)
)
(logior! (-> self flags) (robotank-flag r2))
(sleep-code)
)
:post (behavior ()
(when (logtest? (-> self flags) (robotank-flag r2))
(let* ((gp-0 *target*)
(a0-1 (if (type? gp-0 process-focusable)
gp-0
)
)
)
(cond
(a0-1
(get-trans a0-1 0)
)
(else
)
)
)
(let ((gp-1 (-> self path-info data (-> self path-index))))
(let* ((s5-0 (the-as factory-manager (handle->process (-> self mgr))))
(s2-0 (-> s5-0 tpath path (-> self path-index)))
(s1-0 (new 'stack-no-clear 'vector))
(f28-0 (-> gp-1 u))
(s3-0 (new 'stack-no-clear 'vector))
(s4-0 (-> self root))
(f30-0 (seconds-per-frame))
)
(get-point-at-percent-along-path! s2-0 (-> s4-0 trans) f28-0 'interp)
(+! (-> s4-0 trans y) 1024.0)
(displacement-between-points-at-percent-normalized! s2-0 s3-0 f28-0)
(path-control-method-15 s2-0 s1-0 f28-0 (-> gp-1 du-final))
(seek-toward-heading-vec! s4-0 s3-0 16384.0 (seconds 0.02))
(set! (-> gp-1 prev-u) (-> gp-1 u))
(set! (-> gp-1 u)
(path-control-method-26 (-> s5-0 tpath path (-> self path-index)) (-> gp-1 u) (* 40960.0 f30-0))
)
)
(if (>= (-> gp-1 u) 1.0)
(go-virtual die)
)
)
0
)
(when (time-elapsed? (-> self snd-cmd-time) (seconds 0.5))
(sound-play "tank-engine" :id (-> self engine-sound) :vol 80 :position (-> self root trans))
(set! (-> self engine-sound-playing) #t)
(set-time! (-> self snd-cmd-time))
)
(fac-robotank-post)
)
)
(defstate pause (fac-robotank)
:virtual #t
:event fac-robotank-handler
:enter (behavior ()
'()
)
:trans (behavior ()
(when (logtest? (-> self flags) (robotank-flag r5))
(logclear! (-> self flags) (robotank-flag r5))
(go-virtual moving)
)
)
:code sleep-code
:post fac-robotank-post
)
;; WARN: Return type mismatch (pointer process) vs (pointer joint-exploder).
(defmethod go-explode ((this fac-robotank))
(rlet ((acc :class vf)
(vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
(vf7 :class vf)
)
(init-vf0-vector)
(sound-play "tank-explode")
(cond
((logtest? (-> *part-group-id-table* 732 flags) (sp-group-flag sp13))
(set! (-> *launch-matrix* trans quad) (-> this root trans quad))
(part-tracker-spawn part-tracker-subsampler :to *entity-pool* :group (-> *part-group-id-table* 732))
)
(else
(set! (-> *launch-matrix* trans quad) (-> this root trans quad))
(part-tracker-spawn part-tracker :to *entity-pool* :group (-> *part-group-id-table* 732))
)
)
(let ((s5-3 (new 'stack 'joint-exploder-tuning (the-as uint 0))))
(let ((v1-34 (new 'stack-no-clear 'vector)))
(let ((a0-17 (-> s5-3 fountain-rand-transv-lo)))
(let ((a1-9 (-> this root trans)))
(let ((a2-12 *up-vector*))
(let ((a3-6 2048.0))
(.mov vf7 a3-6)
)
(.lvf vf5 (&-> a2-12 quad))
)
(.lvf vf4 (&-> a1-9 quad))
)
(.add.x.vf vf6 vf0 vf0 :mask #b1000)
(.mul.x.vf acc vf5 vf7 :mask #b111)
(.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111)
(.svf (&-> a0-17 quad) vf6)
)
(vector-float*! v1-34 *up-vector* 81920.0)
(let ((a2-14 (-> s5-3 fountain-rand-transv-lo)))
(let ((a0-20 v1-34))
(let ((a1-11 *identity-vector*))
(let ((a3-8 -40960.0))
(.mov vf7 a3-8)
)
(.lvf vf5 (&-> a1-11 quad))
)
(.lvf vf4 (&-> a0-20 quad))
)
(.add.x.vf vf6 vf0 vf0 :mask #b1000)
(.mul.x.vf acc vf5 vf7 :mask #b111)
(.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111)
(.svf (&-> a2-14 quad) vf6)
)
(let ((a1-12 (-> s5-3 fountain-rand-transv-hi)))
(let ((a0-21 *identity-vector*))
(let ((a2-16 40960.0))
(.mov vf7 a2-16)
)
(.lvf vf5 (&-> a0-21 quad))
)
(.lvf vf4 (&-> v1-34 quad))
(.add.x.vf vf6 vf0 vf0 :mask #b1000)
(.mul.x.vf acc vf5 vf7 :mask #b111)
(.add.mul.w.vf vf6 vf4 vf0 acc :mask #b111)
(.svf (&-> a1-12 quad) vf6)
)
)
(set! (-> s5-3 gravity) -122880.0)
(set! (-> s5-3 rot-speed) 16.0)
(process-spawn
joint-exploder
(art-group-get-by-name *level* "skel-fac-robotank-explode" (the-as (pointer level) #f))
9
s5-3
*fac-robotank-exploder-params*
:name "joint-exploder"
:to this
:unk 0
)
)
)
)
(defstate die (fac-robotank)
:virtual #t
:code (behavior ()
(send-event (handle->process (-> self turret)) 'die)
(let ((v1-7 (-> self root root-prim)))
(set! (-> v1-7 prim-core collide-as) (collide-spec))
(set! (-> v1-7 prim-core collide-with) (collide-spec))
)
0
(logior! (-> self draw status) (draw-control-status no-draw))
(let ((gp-0 (current-time)))
(until (time-elapsed? gp-0 (seconds 2))
(suspend)
)
)
(while (-> self child)
(suspend)
)
(let ((v1-20 (handle->process (-> self mgr))))
(+! (-> v1-20 stack 2) -1)
)
)
)
(defmethod deactivate ((this fac-robotank))
"Make a process dead, clean it up, remove it from the active pool, and return to dead pool."
(if (-> this engine-sound-playing)
(sound-stop (-> this engine-sound))
)
(if (nonzero? (-> this barrel-part))
(kill-particles (-> this barrel-part))
)
((method-of-type process-drawable deactivate) this)
(none)
)
(defmethod relocate ((this fac-robotank) (offset int))
(if (nonzero? (-> this barrel-part))
(&+! (-> this barrel-part) offset)
)
(if (nonzero? (-> this path-info))
(&+! (-> this path-info) offset)
)
;; og:preserve-this
(dotimes (v1-8 2)
(dotimes (a0-1 7)
(if (nonzero? (-> this tread v1-8 wheel a0-1 jmod))
(&+! (-> this tread v1-8 wheel a0-1 jmod) offset)
)
)
)
(call-parent-method this offset)
)
(defbehavior fac-robotank-birth-path fac-robotank ((arg0 factory-manager))
(local-vars (v0-0 int))
0
(until (not (logtest? (-> arg0 tpath inout v0-0 flags) (factory-inout-flag fi0 fi2)))
(set! v0-0 (rand-vu-int-range 0 (+ (-> arg0 tpath npath) -1)))
)
v0-0
)
(defbehavior fac-robotank-init-by-other fac-robotank ()
(set! (-> self mgr) (ppointer->handle (-> self parent)))
(let ((gp-0 (new 'process 'collide-shape-moving self (collide-list-enum usually-hit-by-player))))
(set! (-> gp-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> gp-0 reaction) cshape-reaction-default)
(set! (-> gp-0 no-reaction)
(the-as (function collide-shape-moving collide-query vector vector object) nothing)
)
(let ((s5-0 (new 'process 'collide-shape-prim-group gp-0 (the-as uint 1) 0)))
(set! (-> gp-0 total-prims) (the-as uint 2))
(set! (-> s5-0 prim-core collide-as) (collide-spec enemy obstacle camera-blocker pusher))
(set! (-> s5-0 prim-core collide-with) (collide-spec jak bot player-list))
(set! (-> s5-0 prim-core action) (collide-action solid))
(set-vector! (-> s5-0 local-sphere) 0.0 0.0 0.0 47104.0)
(set! (-> gp-0 root-prim) s5-0)
)
(pusher-init gp-0)
(let ((v1-17 (new 'process 'collide-shape-prim-sphere gp-0 (the-as uint 0))))
(set! (-> v1-17 prim-core collide-as) (collide-spec enemy obstacle))
(set! (-> v1-17 prim-core action) (collide-action solid))
(set-vector! (-> v1-17 local-sphere) 0.0 0.0 0.0 32768.0)
)
(set! (-> gp-0 nav-radius) (* 0.75 (-> gp-0 root-prim local-sphere w)))
(let ((v1-20 (-> gp-0 root-prim)))
(set! (-> gp-0 backup-collide-as) (-> v1-20 prim-core collide-as))
(set! (-> gp-0 backup-collide-with) (-> v1-20 prim-core collide-with))
)
(set! (-> self root) gp-0)
)
(quaternion-identity! (-> self root quat))
(vector-identity! (-> self root scale))
(set! (-> self level) (level-get *level* 'factoryb))
(initialize-skeleton
self
(the-as skeleton-group (art-group-get-by-name *level* "skel-fac-robotank" (the-as (pointer level) #f)))
(the-as pair 0)
)
(set! (-> self explode-sg)
(the-as
skeleton-group
(art-group-get-by-name *level* "skel-fac-robotank-explode" (the-as (pointer level) #f))
)
)
(logclear! (-> self mask) (process-mask actor-pause))
(process-entity-status! self (entity-perm-status no-kill) #t)
(set! (-> self draw light-index) (the-as uint 10))
(set! (-> self fact)
(new 'process 'fact-info self (pickup-type eco-pill-random) (-> *FACT-bank* default-eco-pill-green-inc))
)
(set! (-> self flags) (robotank-flag))
(set! (-> self no-collision-timer) 0)
(set! (-> self engine-vibe-rate) 1.0)
(set! (-> self buzz-timer) 0)
(let* ((v1-37 *game-info*)
(a0-24 (+ (-> v1-37 attack-id) 1))
)
(set! (-> v1-37 attack-id) a0-24)
(set! (-> self attack-id) a0-24)
)
(set! (-> self hit-points) 1.0)
(let ((gp-2 (handle->process (-> self mgr))))
(set! (-> self path-count) (-> (the-as factory-manager gp-2) tpath npath))
(set! (-> self path-info) (new 'process 'fac-robotank-path-info-array (-> self path-count)))
(set! (-> self path-index) (fac-robotank-birth-path (the-as factory-manager (handle->process (-> self mgr)))))
(set! (-> self continue-index) -1)
(let ((s5-2 (new 'stack-no-clear 'vector)))
(get-point-at-percent-along-path!
(-> (the-as factory-manager gp-2) tpath path 0)
(-> self root trans)
0.0
'interp
)
(+! (-> self root trans y) 1024.0)
(displacement-between-points-at-percent-normalized! (-> (the-as factory-manager gp-2) tpath path 0) s5-2 0.0)
(set-heading-vec! (-> self root) s5-2)
)
)
(ja-no-eval :group! fac-robotank-idle-ja :num! zero)
(transform-post)
(let ((gp-3 (new 'stack-no-clear 'vector)))
(set-vector! gp-3 0.0 12541.952 -6778.88 1.0)
(set! (-> self turret) (ppointer->handle (process-spawn
fac-robotank-turret
(-> self root trans)
(-> self root quat)
gp-3
32.0
:name "fac-robotank-turret"
:to self
)
)
)
)
(init (-> self vibe-jmod) self (the-as uint 4) (joint-mod-base-flags attached))
(set! (-> self vibe-jmod blend) 0.5)
(quaternion-axis-angle! (-> self vibe-jmod transform quat) 0.0 0.0 1.0 0.0)
(let ((gp-4 (-> self tread)))
(set! (-> gp-4 0 wheel 0 jmod) (new 'process 'joint-mod-spinner self 5 *x-vector* 0.0))
(set! (-> gp-4 0 wheel 0 radius) 2048.0)
)
(let ((gp-5 (the-as object (&-> self stack 240))))
(set! (-> (the-as fac-robotank-tread-info gp-5) wheel 0 jmod)
(new 'process 'joint-mod-spinner self 6 *x-vector* 0.0)
)
(set! (-> (the-as fac-robotank-tread-info gp-5) wheel 0 radius) 2048.0)
)
(let ((gp-6 (the-as fac-robotank-tread-info (&-> self stack 256))))
(set! (-> gp-6 wheel 0 jmod) (new 'process 'joint-mod-spinner self 7 *x-vector* 0.0))
(set! (-> gp-6 wheel 0 radius) 2048.0)
)
(let ((gp-7 (the-as fac-robotank-tread-info (&-> self stack 272))))
(set! (-> gp-7 wheel 0 jmod) (new 'process 'joint-mod-spinner self 8 *x-vector* 0.0))
(set! (-> gp-7 wheel 0 radius) 2048.0)
)
(let ((gp-8 (the-as fac-robotank-tread-info (&-> self stack 288))))
(set! (-> gp-8 wheel 0 jmod) (new 'process 'joint-mod-spinner self 9 *x-vector* 0.0))
(set! (-> gp-8 wheel 0 radius) 2048.0)
)
(let ((gp-9 (the-as fac-robotank-tread-info (&-> self stack 304))))
(set! (-> gp-9 wheel 0 jmod) (new 'process 'joint-mod-spinner self 10 *x-vector* 0.0))
(set! (-> gp-9 wheel 0 radius) 2048.0)
)
(let ((gp-10 (the-as fac-robotank-tread-info (&-> self stack 320))))
(set! (-> gp-10 wheel 0 jmod) (new 'process 'joint-mod-spinner self 11 *x-vector* 0.0))
(set! (-> gp-10 wheel 0 radius) 2048.0)
)
(let ((gp-11 (-> self tread 1)))
(set! (-> gp-11 wheel 0 jmod) (new 'process 'joint-mod-spinner self 12 *x-vector* 0.0))
(set! (-> gp-11 wheel 0 radius) 2048.0)
)
(let ((gp-12 (the-as fac-robotank-tread-info (&-> self stack 384))))
(set! (-> gp-12 wheel 0 jmod) (new 'process 'joint-mod-spinner self 13 *x-vector* 0.0))
(set! (-> gp-12 wheel 0 radius) 2048.0)
)
(let ((gp-13 (the-as fac-robotank-tread-info (&-> self stack 400))))
(set! (-> gp-13 wheel 0 jmod) (new 'process 'joint-mod-spinner self 14 *x-vector* 0.0))
(set! (-> gp-13 wheel 0 radius) 2048.0)
)
(let ((gp-14 (the-as fac-robotank-tread-info (&-> self stack 416))))
(set! (-> gp-14 wheel 0 jmod) (new 'process 'joint-mod-spinner self 15 *x-vector* 0.0))
(set! (-> gp-14 wheel 0 radius) 2048.0)
)
(let ((gp-15 (the-as fac-robotank-tread-info (&-> self stack 432))))
(set! (-> gp-15 wheel 0 jmod) (new 'process 'joint-mod-spinner self 16 *x-vector* 0.0))
(set! (-> gp-15 wheel 0 radius) 2048.0)
)
(let ((gp-16 (the-as fac-robotank-tread-info (&-> self stack 448))))
(set! (-> gp-16 wheel 0 jmod) (new 'process 'joint-mod-spinner self 17 *x-vector* 0.0))
(set! (-> gp-16 wheel 0 radius) 2048.0)
)
(let ((gp-17 (the-as fac-robotank-tread-info (&-> self stack 464))))
(set! (-> gp-17 wheel 0 jmod) (new 'process 'joint-mod-spinner self 18 *x-vector* 0.0))
(set! (-> gp-17 wheel 0 radius) 2048.0)
)
(let ((v1-105 8))
(set! (-> self tread 0 locator-joint) v1-105)
(vector<-cspace! (-> self tread 0 pos) (-> self node-list data v1-105))
)
(let ((v1-109 15))
(set! (-> self tread 1 locator-joint) v1-109)
(vector<-cspace! (-> self tread 1 pos) (-> self node-list data v1-109))
)
(set-vector! (-> self pov-cam-offset 0) 0.0 13516.8 -13516.8 1.0)
(set-vector! (-> self pov-cam-offset 1) 0.0 13516.8 -13516.8 1.0)
(set! (-> self part) (create-launch-control (-> *part-group-id-table* 782) self))
(set! (-> self barrel-part) (create-launch-control (-> *part-group-id-table* 783) self))
(set! (-> self engine-sound) (new-sound-id))
(set! (-> self engine-sound-playing) #f)
(set-time! (-> self snd-cmd-time))
(go-virtual moving)
)
;; WARN: Return type mismatch process vs fac-robotank.
(defun fac-robotank-spawn ((arg0 process))
(let ((gp-0 (the-as process #f)))
(let ((v1-1 (process-spawn fac-robotank :name "fac-robotank" :to arg0)))
(if v1-1
(set! gp-0 (-> v1-1 0))
)
)
(the-as fac-robotank gp-0)
)
)