mirror of
https://github.com/open-goal/jak-project
synced 2026-05-31 17:32:51 -04:00
c162c66118
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:  > 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: 
829 lines
36 KiB
Common Lisp
829 lines
36 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
(require "engine/geometry/path-h.gc")
|
|
(require "engine/anim/joint-mod-h.gc")
|
|
(require "engine/game/task/task-control.gc")
|
|
(require "engine/common-obs/collectables.gc")
|
|
(require "engine/game/main.gc")
|
|
(defmacro is-nan-hack (flt)
|
|
`(and (< 0.0 ,flt) (< ,flt 0.0)))
|
|
|
|
(defmacro less-than-hack (a b)
|
|
`(if (is-nan-hack ,a) #f (< ,a ,b)))
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(defmethod process-taskable-method-52 ((this process-taskable))
|
|
(let ((v1-1 (-> this draw shadow-ctrl)))
|
|
(when v1-1
|
|
(let ((a0-1 v1-1)) (set! (-> a0-1 settings bot-plane w) (- -12288.0)))
|
|
0
|
|
(set! (-> v1-1 settings top-plane w) (- 4096.0))
|
|
0))
|
|
(none))
|
|
|
|
(defmethod init! ((this gui-query) (arg0 string) (arg1 int) (arg2 int) (arg3 int) (arg4 symbol) (arg5 string))
|
|
(set! (-> this x-position) arg1)
|
|
(set! (-> this y-position) arg2)
|
|
(set! (-> this message-space) arg3)
|
|
(set! (-> this only-allow-cancel) arg4)
|
|
(set! (-> this message) arg0)
|
|
(set! (-> this decision) 'undecided)
|
|
(set! (-> this no-msg) arg5)
|
|
0
|
|
(none))
|
|
|
|
(defmethod get-response ((this gui-query))
|
|
(kill-current-level-hint '() '(sidekick voicebox stinger) 'exit)
|
|
(level-hint-surpress!)
|
|
(hide-hud)
|
|
(when (hud-hidden?)
|
|
(when (-> this message)
|
|
(let ((a1-2 (new 'stack
|
|
'font-context
|
|
*font-default-matrix*
|
|
(-> this x-position)
|
|
(-> this y-position)
|
|
0.0
|
|
(font-color default)
|
|
(font-flags shadow kerning))))
|
|
(let ((v1-4 a1-2)) (set! (-> v1-4 width) (the float (- 512 (-> this x-position)))))
|
|
(let ((v1-5 a1-2)) (set! (-> v1-5 height) (the float 40)))
|
|
(let ((v1-6 a1-2)) (set! (-> v1-6 scale) 0.9))
|
|
(set! (-> a1-2 flags) (font-flags shadow kerning middle-vert large))
|
|
(print-game-text (-> this message) a1-2 #f 128 22)))
|
|
;; og:preserve-this PAL patch here
|
|
(cond
|
|
((-> this only-allow-cancel)
|
|
(when (-> this no-msg)
|
|
(clear *temp-string*)
|
|
(format *temp-string* "; = ~S" (-> this no-msg))
|
|
(let ((a1-5 (new 'stack
|
|
'font-context
|
|
*font-default-matrix*
|
|
(-> this x-position)
|
|
(+ (-> this y-position) 5 (-> this message-space))
|
|
0.0
|
|
(font-color default)
|
|
(font-flags shadow kerning))))
|
|
(let ((v1-15 a1-5)) (set! (-> v1-15 width) (the float 400)))
|
|
(let ((v1-16 a1-5)) (set! (-> v1-16 height) (the float 100)))
|
|
(set! (-> a1-5 flags) (font-flags shadow kerning large))
|
|
(print-game-text *temp-string* a1-5 #f 128 22))))
|
|
(else
|
|
(let ((s5-0 (new 'stack
|
|
'font-context
|
|
*font-default-matrix*
|
|
(-> this x-position)
|
|
(+ (-> this y-position) 5 (-> this message-space))
|
|
0.0
|
|
(font-color default)
|
|
(font-flags shadow kerning))))
|
|
(let ((v1-22 s5-0)) (set! (-> v1-22 width) (the float 400)))
|
|
(let ((v1-23 s5-0)) (set! (-> v1-23 height) (the float 100)))
|
|
(set! (-> s5-0 flags) (font-flags shadow kerning large))
|
|
(print-game-text (lookup-text! *common-text* (text-id confirm) #f) s5-0 #f 128 22))))
|
|
(cond
|
|
((!= (-> this decision) 'undecided))
|
|
((and (cpad-pressed? 0 x) (not (-> this only-allow-cancel)))
|
|
(logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons x))
|
|
(logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons x))
|
|
(set! (-> this decision) 'yes))
|
|
((cpad-pressed? 0 triangle)
|
|
(logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons triangle))
|
|
(logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons triangle))
|
|
(set! (-> this decision) 'no))))
|
|
(-> this decision))
|
|
|
|
(defmethod relocate ((this process-taskable) (arg0 int))
|
|
(the-as process-taskable ((method-of-type process-drawable relocate) this arg0)))
|
|
|
|
(defmethod process-taskable-method-46 ((this process-taskable))
|
|
(when (nonzero? (-> this sound-flava))
|
|
(let ((s5-1 (vector-! (new 'stack-no-clear 'vector) (target-pos 0) (the-as vector (-> this root root-prim prim-core)))))
|
|
(set! (-> s5-1 y) (* 4.0 (-> s5-1 y)))
|
|
(cond
|
|
;; og:preserve-this s5-1 can be nan on the first frame after something spawns
|
|
((less-than-hack (vector-length s5-1) 102400.0)
|
|
(when (not (-> this have-flava))
|
|
(set! (-> this have-flava) #t)
|
|
(set-setting! 'sound-flava #f 20.0 (-> this sound-flava))))
|
|
((-> this have-flava) (remove-setting! 'sound-flava) (set! (-> this have-flava) #f)))))
|
|
(when (-> this music)
|
|
(let ((s5-3 (vector-! (new 'stack-no-clear 'vector) (target-pos 0) (the-as vector (-> this root root-prim prim-core)))))
|
|
(set! (-> s5-3 y) (* 4.0 (-> s5-3 y)))
|
|
(cond
|
|
((< (vector-length s5-3) 102400.0)
|
|
(when (not (-> this have-music))
|
|
(set! (-> this have-music) #t)
|
|
(set-setting! 'music (-> this music) 0.0 0)))
|
|
((-> this have-music) (remove-setting! 'music) (set! (-> this have-music) #f)))))
|
|
0
|
|
(none))
|
|
|
|
(defmethod get-art-elem ((this process-taskable))
|
|
(the-as art-element (if (> (-> this skel active-channels) 0) (-> this skel root-channel 0 frame-group))))
|
|
|
|
(defmethod play-anim! ((this process-taskable) (arg0 symbol))
|
|
(the-as basic #f))
|
|
|
|
(defmethod process-taskable-method-33 ((this process-taskable))
|
|
(let ((s5-0 (play-anim! this #f)))
|
|
(if (type-type? (-> s5-0 type) spool-anim) (spool-push *art-control* (-> (the-as spool-anim s5-0) name) 0 this -99.0)))
|
|
0
|
|
(none))
|
|
|
|
(defmethod close-anim-file! ((this process-taskable))
|
|
(let* ((gp-0 (play-anim! this #f))
|
|
(v1-2 (if (and (nonzero? gp-0) (type-type? (-> gp-0 type) spool-anim)) gp-0)))
|
|
(if v1-2 (file-status *art-control* (-> (the-as spool-anim v1-2) name) 0))))
|
|
|
|
(defmethod get-accept-anim ((this process-taskable) (arg0 symbol))
|
|
(the-as spool-anim #f))
|
|
|
|
(defmethod push-accept-anim ((this process-taskable))
|
|
(let ((s5-0 (get-accept-anim this #f)))
|
|
(if (type-type? (-> s5-0 type) spool-anim) (spool-push *art-control* (-> s5-0 name) 0 this -99.0)))
|
|
0
|
|
(none))
|
|
|
|
(defmethod get-reject-anim ((this process-taskable) (arg0 symbol))
|
|
(the-as spool-anim #f))
|
|
|
|
(defmethod push-reject-anim ((this process-taskable))
|
|
(let ((s5-0 (get-reject-anim this #f)))
|
|
(if (type-type? (-> s5-0 type) spool-anim) (spool-push *art-control* (-> s5-0 name) 0 this -99.0)))
|
|
0
|
|
(none))
|
|
|
|
(defmethod process-taskable-method-38 ((this process-taskable))
|
|
(if (nonzero? (-> this cell-for-task)) (go (method-of-object this give-cell)))
|
|
(go (method-of-object this release))
|
|
(none))
|
|
|
|
(defbehavior process-taskable-anim-loop process-taskable ()
|
|
(when (!= (ja-group) (get-art-elem self))
|
|
(ja-channel-push! 1 (seconds 0.2))
|
|
(ja :group! (get-art-elem self)))
|
|
(loop
|
|
(suspend)
|
|
(ja :num! (loop!))
|
|
(if (= (-> self next-state name) 'idle) (process-taskable-method-43 self)))
|
|
(the-as none 0)
|
|
(none))
|
|
|
|
(defstate release (process-taskable)
|
|
:virtual #t
|
|
:trans
|
|
(behavior ()
|
|
(when (process-release? *target*)
|
|
(send-event *target* 'trans 'restore (-> self old-target-pos))
|
|
(if (should-display? self) (go-virtual idle) (go-virtual hidden)))
|
|
(process-taskable-method-33 self)
|
|
((-> self cur-trans-hook)))
|
|
:code process-taskable-anim-loop
|
|
:post ja-post)
|
|
|
|
(defstate give-cell (process-taskable)
|
|
:virtual #t
|
|
:trans
|
|
(behavior ()
|
|
(cond
|
|
((nonzero? (-> self cell-for-task))
|
|
(let ((gp-0 (handle->process (-> self cell-x))))
|
|
(when gp-0
|
|
(send-event *target* 'trans 'reset)
|
|
(send-event gp-0 'pickup (target-pos 0))
|
|
(go-virtual idle)))
|
|
(format #t "ERROR<GMJ>: ~S no cell spawned~%" (-> self name))
|
|
(send-event *target* 'get-pickup 6 (the float (-> self cell-for-task))))
|
|
(else
|
|
(format #t
|
|
"ERROR<GMJ>: ~S got into give-cell with give-cell == #f task = ~S~%"
|
|
(-> self name)
|
|
(game-task->string (current-task (-> self tasks))))))
|
|
(go-virtual release)
|
|
(process-taskable-method-33 self)
|
|
((-> self cur-trans-hook)))
|
|
:code process-taskable-anim-loop
|
|
:post ja-post)
|
|
|
|
(defstate lose (process-taskable)
|
|
:virtual #t
|
|
:enter
|
|
(behavior ()
|
|
(set-time! (-> self state-time)))
|
|
:trans
|
|
(behavior ()
|
|
(if (and (time-elapsed? (-> self state-time) (seconds 5))
|
|
(or (not *target*) (< 20480.0 (vector-vector-distance (-> self root trans) (-> *target* control trans)))))
|
|
(go-virtual idle))
|
|
((-> self cur-trans-hook)))
|
|
:code process-taskable-anim-loop
|
|
:post ja-post)
|
|
|
|
(defstate enter-playing (process-taskable)
|
|
:virtual #t
|
|
:code process-taskable-anim-loop
|
|
:post ja-post)
|
|
|
|
(defbehavior process-taskable-play-anim-enter process-taskable ()
|
|
(init! (-> self query) (the-as string #f) 40 150 25 #t (the-as string #f))
|
|
(logior! (-> self skel status) (janim-status blerc))
|
|
(set! (-> self camera) (ppointer->handle (process-spawn othercam self (-> self cam-joint-index) #f #t :to self)))
|
|
(set! (-> self cell-for-task) (game-task none))
|
|
(set! (-> self skippable) #f)
|
|
(set! (-> self blend-on-exit) #f)
|
|
(set! (-> self will-talk) #f)
|
|
#f)
|
|
|
|
(defbehavior process-taskable-play-anim-exit process-taskable ()
|
|
(logclear! (-> self skel status) (janim-status blerc))
|
|
(let ((a0-4 (handle->process (-> self camera)))) (if a0-4 (deactivate a0-4)))
|
|
(set! (-> self last-talk) (-> *display* game-frame-counter))
|
|
(process-taskable-method-52 self)
|
|
(none))
|
|
|
|
(defbehavior process-taskable-play-anim-trans process-taskable ()
|
|
(if (nonzero? *camera-look-through-other*) (set! *camera-look-through-other* 2))
|
|
(set-letterbox-frames (seconds 0.017))
|
|
(draw-npc-shadow self)
|
|
(none))
|
|
|
|
(defbehavior process-taskable-play-anim-code process-taskable ((arg0 art-joint-anim) (arg1 basic))
|
|
(when (nonzero? (-> self cell-for-task))
|
|
(if (name= (-> self state name) "play-anim")
|
|
(set! (-> self cell-x)
|
|
(ppointer->handle (process-spawn fuel-cell :init fuel-cell-init-as-clone (process->handle self) (-> self cell-for-task) :to self)))
|
|
(format #t "ERROR<GMJ>: ~S ~S trying to give cell on release~%" (-> self name) (-> self state name))))
|
|
(cond
|
|
((and arg1 (type-type? (-> arg1 type) spool-anim))
|
|
(when *target*
|
|
(while (not (send-event *target* 'clone-anim self))
|
|
(spool-push *art-control* (-> (the-as spool-anim arg1) name) 0 self -99.0)
|
|
(format #t "WARNING: ~A stall on not cloning.~%" (-> self name))
|
|
(suspend))
|
|
(send-event (ppointer->process (-> *target* sidekick)) 'matrix 'play-anim)
|
|
(send-event *target* 'blend-shape #t))
|
|
(add-setting! 'music-volume 'rel (-> *setting-control* current music-volume-movie) 0)
|
|
(add-setting! 'sfx-volume 'rel (-> *setting-control* current sfx-volume-movie) 0)
|
|
(add-setting! 'ambient-volume 'rel (-> *setting-control* current ambient-volume-movie) 0)
|
|
(if (-> self blend-on-exit) (set! (-> self blend-on-exit) arg0))
|
|
;; og:preserve-this allow cutscene skipping on pc port
|
|
;; save a sort of timestamp just so we know if it took at least 1 frame
|
|
(#when PC_PORT
|
|
(define *play-anim-time* (current-time)))
|
|
(if (#if PC_PORT (= (-> *pc-settings* skip-movies?) #t) (and *debug-segment* *cheat-mode*))
|
|
(ja-play-spooled-anim (the-as spool-anim arg1)
|
|
arg0
|
|
(-> self blend-on-exit)
|
|
(lambda ((arg0 process-taskable))
|
|
(= (get-response (-> arg0 query)) 'no)))
|
|
(ja-play-spooled-anim (the-as spool-anim arg1)
|
|
arg0
|
|
(-> self blend-on-exit)
|
|
(the-as (function process-drawable symbol) false-func)))
|
|
;; og:preserve-this
|
|
(#when PC_PORT
|
|
(if (= (current-time) *play-anim-time*) (suspend)))
|
|
(remove-setting! 'music-volume)
|
|
(remove-setting! 'sfx-volume)
|
|
(remove-setting! 'ambient-volume)
|
|
(send-event *target* 'blend-shape #f))
|
|
(else
|
|
(when (not arg1)
|
|
(format #t "ERROR<GMJ>: ~S ~S got #f from anim picker~%" (-> self name) (-> self state name))
|
|
(set! arg1 (ja-group)))
|
|
(when (not (type-type? (-> arg1 type) art-joint-anim))
|
|
(format 0
|
|
"ERROR<GMJ>: ~S ~S anim picker didn't return spool-anim or joint-art-anim (probably need to override it)~%"
|
|
(-> self name)
|
|
(-> self state name))
|
|
(set! arg1 (ja-group)))
|
|
(format #t "~S ~S anim ~S~%" (-> self name) (-> self state name) (-> (the-as art-joint-anim arg1) name))
|
|
(ja-channel-push! 1 (seconds 0.2))
|
|
(set! (-> self skel root-channel 0 frame-group) (the-as art-joint-anim arg1))
|
|
(when (< (ja-num-frames 0) 3)
|
|
(suspend)
|
|
(suspend)
|
|
0)
|
|
(ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
|
|
(until (ja-done? 0)
|
|
(if (and *debug-segment* (= (get-response (-> self query)) 'no)) (ja :num-func num-func-identity :frame-num max))
|
|
(suspend)
|
|
(ja :num! (seek!)))
|
|
#f)))
|
|
|
|
(defstate play-accept (process-taskable)
|
|
:virtual #t
|
|
:enter process-taskable-play-anim-enter
|
|
:exit process-taskable-play-anim-exit
|
|
:trans
|
|
(behavior ()
|
|
(process-taskable-play-anim-trans)
|
|
((-> self cur-trans-hook)))
|
|
:code
|
|
(behavior ()
|
|
(process-taskable-play-anim-code (the-as art-joint-anim (get-art-elem self)) (get-accept-anim self #t))
|
|
(while (not (process-release? *target*))
|
|
(suspend))
|
|
(go-virtual enter-playing))
|
|
:post ja-post)
|
|
|
|
(defstate play-reject (process-taskable)
|
|
:virtual #t
|
|
:enter process-taskable-play-anim-enter
|
|
:exit process-taskable-play-anim-exit
|
|
:trans
|
|
(behavior ()
|
|
(process-taskable-play-anim-trans)
|
|
((-> self cur-trans-hook)))
|
|
:code
|
|
(behavior ()
|
|
(process-taskable-play-anim-code (the-as art-joint-anim (get-art-elem self)) (get-reject-anim self #t))
|
|
(go-virtual release))
|
|
:post ja-post)
|
|
|
|
(defstate query (process-taskable)
|
|
:virtual #t
|
|
:enter
|
|
(behavior ()
|
|
(init! (-> self query)
|
|
(lookup-text! *common-text* (text-id confirm-play) #f)
|
|
40
|
|
150
|
|
25
|
|
#f
|
|
(lookup-text! *common-text* (text-id quit) #f)))
|
|
:exit process-taskable-play-anim-exit
|
|
:trans
|
|
(behavior ()
|
|
(case (current-status (-> self tasks))
|
|
(((task-status need-reminder-a))
|
|
(case (get-response (-> self query))
|
|
(('yes) (go-virtual play-accept))
|
|
(('no) (go-virtual play-reject)))
|
|
(push-accept-anim self))
|
|
(else
|
|
(let ((gp-0 (get-response (-> self query))))
|
|
(cond
|
|
((and (= gp-0 'yes) (process-release? *target*)) (go-virtual enter-playing))
|
|
((= gp-0 'no) (go-virtual play-reject))))))
|
|
(push-reject-anim self)
|
|
(set! *camera-look-through-other* 2)
|
|
((-> self cur-trans-hook)))
|
|
:code process-taskable-anim-loop
|
|
:post ja-post)
|
|
|
|
(defstate play-anim (process-taskable)
|
|
:virtual #t
|
|
:event
|
|
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
|
|
(case message
|
|
(('shadow)
|
|
(cond
|
|
((-> block param 0)
|
|
(let ((v0-0 (the-as object (-> self shadow-backup)))) (set! (-> self draw shadow) (the-as shadow-geo v0-0)) v0-0))
|
|
(else (set! (-> self draw shadow) #f) #f)))
|
|
(('shadow-min-max)
|
|
(let ((v1-5 (-> self draw shadow-ctrl)))
|
|
(let ((a0-4 v1-5)) (set! (-> a0-4 settings bot-plane w) (- (the-as float (-> block param 0)))))
|
|
0
|
|
(set! (-> v1-5 settings top-plane w) (- (the-as float (-> block param 1)))))
|
|
0)))
|
|
:enter process-taskable-play-anim-enter
|
|
:exit process-taskable-play-anim-exit
|
|
:trans
|
|
(behavior ()
|
|
(process-taskable-play-anim-trans)
|
|
(let ((a3-0 (handle->process (-> self cell-x))))
|
|
(if a3-0 (spool-push *art-control* (-> self fuel-cell-anim name) 0 a3-0 -99.0)))
|
|
((-> self cur-trans-hook)))
|
|
:code
|
|
(behavior ()
|
|
(process-taskable-play-anim-code (the-as art-joint-anim (get-art-elem self)) (play-anim! self #t))
|
|
(process-taskable-method-38 self))
|
|
:post ja-post)
|
|
|
|
(defbehavior process-taskable-clean-up-after-talking process-taskable ()
|
|
(logclear! (-> self draw status) (draw-status hidden))
|
|
(logclear! (-> self skel status) (janim-status inited))
|
|
(remove-setting! 'border-mode)
|
|
(remove-setting! 'talking)
|
|
(none))
|
|
|
|
(defmethod should-display? ((this process-taskable))
|
|
#t)
|
|
|
|
(defbehavior process-taskable-hide-handler process-taskable ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
|
|
(case arg2
|
|
(('clone) (go-virtual be-clone (the-as handle (-> arg3 param 0))))
|
|
(('play-anim) (logclear! (-> self mask) (process-mask actor-pause)) (set! (-> self been-kicked) #t) (go-virtual idle))
|
|
(('hidden-other) (go-virtual hidden-other))))
|
|
|
|
(defbehavior process-taskable-hide-enter process-taskable ()
|
|
(set-time! (-> self state-time))
|
|
(let ((v1-3 (-> self draw shadow-ctrl))) (logior! (-> v1-3 settings flags) (shadow-flags disable-draw)))
|
|
0
|
|
(process-taskable-clean-up-after-talking)
|
|
(clear-collide-with-as (-> self root))
|
|
(ja-channel-set! 0)
|
|
(the-as int (ja-post)))
|
|
|
|
(defbehavior process-taskable-hide-exit process-taskable ((arg0 symbol))
|
|
(cond
|
|
(arg0 (process-entity-status! self (entity-perm-status bit-3) #f))
|
|
(else
|
|
(ja-channel-set! 1)
|
|
(ja :group! (get-art-elem self))
|
|
(restore-collide-with-as (-> self root))
|
|
(process-entity-status! self (entity-perm-status bit-3) #t)
|
|
(let ((v1-7 (-> self draw shadow-ctrl))) (logclear! (-> v1-7 settings flags) (shadow-flags disable-draw)))
|
|
0))
|
|
(none))
|
|
|
|
(defstate hidden (process-taskable)
|
|
:virtual #t
|
|
:event process-taskable-hide-handler
|
|
:enter process-taskable-hide-enter
|
|
:exit
|
|
(behavior ()
|
|
(process-taskable-hide-exit (= (-> self next-state name) 'hidden)))
|
|
:trans
|
|
(behavior ()
|
|
(if (time-elapsed? (-> self state-time) (seconds 1)) (process-entity-status! self (entity-perm-status bit-3) #f))
|
|
(if (or (-> self been-kicked) (should-display? self)) (go-virtual idle)))
|
|
:code anim-loop)
|
|
|
|
;; WARN: disable def twice: 4. This may happen when a cond (no else) is nested inside of another conditional, but it should be rare.
|
|
(defmethod process-taskable-method-50 ((this process-taskable))
|
|
(if *target*
|
|
(or (not *target*) (< 245760.0 (vector-vector-distance (-> this root trans) (-> *target* control trans))))
|
|
(< 60397978000.0 (vector-vector-distance-squared (the-as vector (-> this root root-prim prim-core)) (camera-pos)))))
|
|
|
|
(defstate hidden-other (process-taskable)
|
|
:virtual #t
|
|
:event process-taskable-hide-handler
|
|
:enter process-taskable-hide-enter
|
|
:exit
|
|
(behavior ()
|
|
(process-taskable-hide-exit (= (-> self next-state name) 'hidden-other)))
|
|
:trans
|
|
(behavior ()
|
|
(if (time-elapsed? (-> self state-time) (seconds 1)) (process-entity-status! self (entity-perm-status bit-3) #f))
|
|
(cond
|
|
((-> self been-kicked) (go-virtual idle))
|
|
((process-taskable-method-50 self) (if (should-display? self) (go-virtual idle) (go-virtual hidden)))))
|
|
:code anim-loop)
|
|
|
|
(defstate be-clone (process-taskable)
|
|
:virtual #t
|
|
:event
|
|
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
|
|
(the-as shadow-geo
|
|
(case message
|
|
(('shadow)
|
|
(the-as shadow-geo
|
|
(cond
|
|
((-> block param 0) (let ((v0-0 (-> self shadow-backup))) (set! (-> self draw shadow) v0-0) v0-0))
|
|
(else (set! (-> self draw shadow) #f) (the-as shadow-geo #f)))))
|
|
(('shadow-min-max)
|
|
(let ((v1-5 (-> self draw shadow-ctrl)))
|
|
(let ((a0-5 v1-5)) (set! (-> a0-5 settings bot-plane w) (- (the-as float (-> block param 0)))))
|
|
0
|
|
(set! (-> v1-5 settings top-plane w) (- (the-as float (-> block param 1)))))
|
|
(the-as shadow-geo 0))
|
|
(('end-mode)
|
|
(the-as shadow-geo
|
|
(if (should-display? self) (the-as shadow-geo (go-virtual idle)) (the-as shadow-geo (go-virtual hidden))))))))
|
|
:enter
|
|
(behavior ((arg0 handle))
|
|
(logior! (-> self skel status) (janim-status blerc))
|
|
(logclear! (-> self mask) (process-mask actor-pause))
|
|
(set-vector! (-> self draw bounds) 0.0 (-> self draw-bounds-y-offset) 0.0 (-> self draw bounds w)))
|
|
:exit
|
|
(behavior ()
|
|
(logclear! (-> self skel status) (janim-status blerc spool))
|
|
(logior! (-> self mask) (process-mask actor-pause))
|
|
(let ((v1-6 (-> self entity extra trans))) (if v1-6 (set! (-> self root trans quad) (-> v1-6 quad))))
|
|
(ja-channel-set! 0))
|
|
:trans
|
|
(behavior ()
|
|
(draw-npc-shadow self)
|
|
((-> self cur-trans-hook)))
|
|
:code
|
|
(behavior ((arg0 handle))
|
|
(clone-anim arg0 (-> self center-joint-index) #t "")
|
|
(format #t "ERROR<GMJ>: handle invalid while ~S is cloning~%" (-> self name))
|
|
(go-virtual hidden)))
|
|
|
|
(defmethod target-above-threshold? ((this process-taskable))
|
|
#t)
|
|
|
|
(defstate idle (process-taskable)
|
|
:virtual #t
|
|
:event
|
|
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
|
|
(the-as symbol
|
|
(case message
|
|
(('attack)
|
|
(the-as symbol
|
|
(if (-> self bounce-away)
|
|
(the-as symbol (send-event proc 'shove #f (static-attack-info ((shove-back (meters 3)) (shove-up (meters 1)))))))))
|
|
(('touch)
|
|
(the-as symbol
|
|
(send-shove-back (-> self root) proc (the-as touching-shapes-entry (-> block param 0)) 0.7 6144.0 16384.0)))
|
|
(('clone) (the-as symbol (go-virtual be-clone (the-as handle (-> block param 0)))))
|
|
(('play-anim)
|
|
(logclear! (-> self mask) (process-mask actor-pause))
|
|
(let ((v0-0 #t)) (set! (-> self been-kicked) v0-0) v0-0))
|
|
(('hidden-other) (the-as symbol (go-virtual hidden-other))))))
|
|
:enter
|
|
(behavior ()
|
|
(set-time! (-> self state-time))
|
|
(process-taskable-clean-up-after-talking))
|
|
:exit
|
|
(behavior ()
|
|
(cond
|
|
((or (= (-> self next-state name) 'dead-state) (= (-> self next-state name) 'idle))
|
|
(process-entity-status! self (entity-perm-status bit-3) #f))
|
|
(else
|
|
(kill-current-level-hint '() '() 'exit)
|
|
(logior! (-> self skel status) (janim-status inited))
|
|
(logclear! (-> self mask) (process-mask actor-pause))
|
|
(process-entity-status! self (entity-perm-status bit-3) #t)
|
|
(set-setting! 'border-mode #f 0.0 0)
|
|
(set-setting! 'talking (process->ppointer self) 0.0 0)
|
|
(apply-settings *setting-control*))))
|
|
:trans
|
|
(behavior ()
|
|
(when (time-elapsed? (-> self state-time) (seconds 0.2))
|
|
(logior! (-> self mask) (process-mask actor-pause))
|
|
(process-entity-status! self (entity-perm-status bit-3) #f))
|
|
(cond
|
|
((not *target*))
|
|
((not (-> self will-talk))
|
|
(if (>= (- (-> *display* game-frame-counter) (-> self last-talk)) (seconds 10)) (set! (-> self will-talk) #t)))
|
|
((begin
|
|
(process-taskable-method-46 self)
|
|
(and (not (and (logtest? (-> *target* control unknown-surface00 flags) (surface-flags jump))
|
|
(not (logtest? (-> *target* control status) (cshape-moving-flags onsurf)))))
|
|
(< (-> (target-pos 0) y) (+ 8192.0 (-> self root root-prim prim-core world-sphere y)))
|
|
;; og:preserve-this
|
|
(less-than-hack (vector-vector-distance (target-pos 0) (the-as vector (-> self root root-prim prim-core))) 32768.0)
|
|
(= (-> *level* loading-level) (-> *level* level-default))
|
|
(not (movie?))
|
|
(not (level-hint-displayed?))
|
|
(none-reserved? *art-control*)
|
|
(not *progress-process*)
|
|
(and (not (handle->process (-> *game-info* other-camera-handle))) (close-anim-file! self))))
|
|
(first-any (-> self tasks) #t)
|
|
(when (target-above-threshold? self)
|
|
(case (current-status (-> self tasks))
|
|
(((task-status need-hint)
|
|
(task-status need-introduction)
|
|
(task-status need-reminder)
|
|
(task-status need-reminder-a)
|
|
(task-status need-reward-speech))
|
|
(kill-current-level-hint '() '(sidekick voicebox ambient) 'exit)
|
|
(level-hint-surpress!)
|
|
(hide-hud)
|
|
(when (and (hud-hidden?) (can-grab-display? self))
|
|
(let ((gp-1 (new 'stack 'font-context *font-default-matrix* 32 140 0.0 (font-color default) (font-flags shadow kerning))))
|
|
(let ((v1-57 gp-1)) (set! (-> v1-57 width) (the float 440)))
|
|
(let ((v1-58 gp-1)) (set! (-> v1-58 height) (the float 60)))
|
|
(let ((v1-59 gp-1)) (set! (-> v1-59 scale) 0.9))
|
|
(set! (-> gp-1 flags) (font-flags shadow kerning middle-vert large))
|
|
(print-game-text (lookup-text! *common-text* (-> self talk-message) #f) gp-1 #f 128 22))
|
|
(when (and (cpad-pressed? 0 circle) (process-grab? *target*))
|
|
(logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons circle))
|
|
(logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons circle))
|
|
(send-event *target* 'trans 'save (-> self old-target-pos))
|
|
(go-virtual play-anim))))))))
|
|
(if (= (-> *level* loading-level) (-> *level* level-default)) (process-taskable-method-33 self))
|
|
(draw-npc-shadow self)
|
|
(when (and (-> self been-kicked)
|
|
(and (not *progress-process*) (process-grab? *target*) (not (handle->process (-> *game-info* other-camera-handle)))))
|
|
(set! (-> self been-kicked) #f)
|
|
(send-event *target* 'trans 'save (-> self old-target-pos))
|
|
(go-virtual play-anim))
|
|
((-> self cur-trans-hook)))
|
|
:code process-taskable-anim-loop
|
|
:post
|
|
(behavior ()
|
|
(when *target*
|
|
(when (!= (-> self neck-joint-index) -1)
|
|
(let ((gp-0 (new 'stack-no-clear 'vector)))
|
|
(vector<-cspace! gp-0 (-> self node-list data (-> self neck-joint-index)))
|
|
(if *target* (look-at-enemy! (-> *target* neck) gp-0 'nothing self)))))
|
|
(transform-post)))
|
|
|
|
(defmethod initialize-collision ((this process-taskable) (arg0 int) (arg1 vector))
|
|
(let ((s5-0 (new 'process 'collide-shape this (collide-list-enum hit-by-player))))
|
|
(let ((s4-0 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 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! (-> s4-0 prim-core offense) (collide-offense indestructible))
|
|
(set! (-> s4-0 transform-index) arg0)
|
|
(set-vector! (-> s4-0 local-sphere) (-> arg1 x) (-> arg1 y) (-> arg1 z) (-> arg1 w))
|
|
(set-root-prim! s5-0 s4-0))
|
|
(set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
|
|
(backup-collide-with-as s5-0)
|
|
(set! (-> this root) s5-0))
|
|
0
|
|
(none))
|
|
|
|
(defmethod process-taskable-method-40 ((this process-taskable) (arg0 object) (arg1 skeleton-group) (arg2 int) (arg3 int) (arg4 vector) (arg5 int))
|
|
(stack-size-set! (-> this main-thread) 512)
|
|
(initialize-collision this arg2 arg4)
|
|
(process-drawable-from-entity! this (the-as entity-actor arg0))
|
|
(initialize-skeleton this arg1 '())
|
|
(set! (-> this shadow-backup) (-> this draw shadow))
|
|
(logior! (-> this skel status) (janim-status eye))
|
|
;; og:preserve-this
|
|
(#when PC_PORT
|
|
(set! (-> this skel postbind-function) process-drawable-joint-callback-pc))
|
|
(set! (-> this root pause-adjust-distance) -122880.0)
|
|
(set! (-> this fuel-cell-anim) (fuel-cell-pick-anim this))
|
|
(set! (-> this draw origin-joint-index) (the-as uint arg2))
|
|
(set! (-> this draw shadow-joint-index) (the-as uint arg2))
|
|
(set! (-> this center-joint-index) arg2)
|
|
(set! (-> this draw-bounds-y-offset) (-> this draw bounds y))
|
|
(set! (-> this have-flava) #f)
|
|
(set! (-> this music) #f)
|
|
(set! (-> this have-music) #f)
|
|
(set! (-> this cam-joint-index) arg3)
|
|
(set! (-> this cell-x) (the-as handle #f))
|
|
(set! (-> this cell-for-task) (game-task none))
|
|
(set! (-> this camera) (the-as handle #f))
|
|
(set! (-> this will-talk) #t)
|
|
(set! (-> this talk-message) (text-id press-to-talk))
|
|
(set! (-> this last-talk) 0)
|
|
(set! (-> this bounce-away) #t)
|
|
(set! (-> this been-kicked) #f)
|
|
(set! (-> this neck-joint-index) arg5)
|
|
(set! (-> this cur-trans-hook) nothing)
|
|
(ambient-control-method-9 (-> this ambient))
|
|
(set! (-> this event-hook) (-> (method-of-object this idle) event))
|
|
(set! (-> this draw shadow-ctrl) (new 'process 'shadow-control 0.0 0.0 614400.0 (the-as float 60) 245760.0))
|
|
(process-taskable-method-52 this)
|
|
0
|
|
(none))
|
|
|
|
(defmethod process-taskable-method-42 ((this process-taskable))
|
|
(cond
|
|
((not (should-display? this)) (go (method-of-object this hidden)))
|
|
((= (current-status (-> this tasks)) (task-status need-resolution)) (go (method-of-object this give-cell)))
|
|
(else (go (method-of-object this idle))))
|
|
(none))
|
|
|
|
(defmethod process-taskable-method-43 ((this process-taskable))
|
|
(the-as symbol 0))
|
|
|
|
(defmethod ambient-control-method-9 ((this ambient-control))
|
|
(set! (-> this last-ambient-time) (-> *display* game-frame-counter))
|
|
0
|
|
(none))
|
|
|
|
(defmethod ambient-control-method-10 ((this ambient-control) (arg0 vector) (arg1 time-frame) (arg2 float) (arg3 process-drawable))
|
|
(when (< (- (-> *display* game-frame-counter) (-> this last-ambient-time)) arg1)
|
|
(set! arg0 (the-as vector #f))
|
|
(goto cfg-6))
|
|
(vector-for-ambient arg3 arg0)
|
|
(when (< arg2 (vector-length arg0))
|
|
(set! arg0 (the-as vector #f))
|
|
(goto cfg-6))
|
|
(label cfg-6)
|
|
arg0)
|
|
|
|
(defmethod play-ambient ((this ambient-control) (arg0 string) (arg1 symbol) (arg2 vector))
|
|
(when (and (not (string= arg0 (-> this last-ambient)))
|
|
(or arg1 (can-hint-be-played? (text-id one) (the-as entity #f) (the-as string #f)))
|
|
(= (-> *level* loading-level) (-> *level* level-default))
|
|
(ambient-hint-spawn arg0 arg2 *entity-pool* 'ambient))
|
|
(set! (-> this last-ambient-time) (-> *display* game-frame-counter))
|
|
(set! (-> this last-ambient) arg0)
|
|
(return #t))
|
|
#f)
|
|
|
|
(defun vector-for-ambient ((arg0 process-drawable) (arg1 vector))
|
|
(if *target* (vector-! arg1 (target-pos 0) (-> arg0 root trans)) (vector-! arg1 (camera-pos) (-> arg0 root trans)))
|
|
arg1)
|
|
|
|
(defun othercam-calc ((arg0 float))
|
|
(set! (-> *camera-other-fov* data) (* 2.0 (atan (/ 14.941477 (* 20.3 arg0)) 1.0)))
|
|
(none))
|
|
|
|
(defstate othercam-running (othercam)
|
|
:event
|
|
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
|
|
(local-vars (v0-0 object))
|
|
(case message
|
|
(('die) (set! v0-0 #t) (set! (-> self die?) (the-as symbol v0-0)) v0-0)
|
|
(('joint)
|
|
(let ((t9-0 type-type?)
|
|
(v1-1 (-> block param 0)))
|
|
(cond
|
|
((t9-0 (rtype-of v1-1) string)
|
|
(let ((v1-8 (lookup-art (-> (the-as process-taskable (-> self hand process 0)) draw jgeo)
|
|
(the-as string (-> block param 0))
|
|
(the-as type #f))))
|
|
(when v1-8
|
|
(set! v0-0 (+ (-> v1-8 number) 1))
|
|
(set! (-> self cam-joint-index) (the-as int v0-0))
|
|
v0-0)))
|
|
((not (logtest? (-> block param 0) 7))
|
|
(set! v0-0 (-> block param 0))
|
|
(set! (-> self cam-joint-index) (the-as int v0-0))
|
|
v0-0))))
|
|
(('mask) (set! v0-0 (-> block param 0)) (set! (-> self mask-to-clear) (the-as process-mask v0-0)) v0-0)))
|
|
:enter
|
|
(behavior ()
|
|
(hide-hud-quick)
|
|
(case (-> self spooling?)
|
|
(('logo))
|
|
(else
|
|
(add-setting! 'process-mask 'set 0.0 (-> self mask-to-clear))
|
|
(add-setting! 'movie (process->ppointer self) 0.0 0)
|
|
(if (not (-> self border-value)) (add-setting! 'border-mode (-> self border-value) 0.0 0))))
|
|
(set! (-> self had-valid-frame) #f)
|
|
(let ((gp-0 (-> self hand process 0)))
|
|
(vector<-cspace! (-> self old-pos) (-> (the-as process-taskable gp-0) node-list data (-> self cam-joint-index)))
|
|
(let ((v1-19 (-> (the-as process-taskable gp-0) node-list data (-> self cam-joint-index) bone transform)))
|
|
(vector-normalize-copy! (-> self old-mat-z) (-> v1-19 vector 2) -1.0)))
|
|
(apply-settings *setting-control*))
|
|
:exit
|
|
(behavior ()
|
|
(remove-setting! 'process-mask)
|
|
(apply-settings *setting-control*))
|
|
:code
|
|
(behavior ()
|
|
(loop
|
|
(let ((s2-0 (-> self hand process 0)))
|
|
(when (not s2-0)
|
|
(format #t "ERROR<GMJ>: othercam parent invalid~%")
|
|
(deactivate self))
|
|
(set! (-> *camera-other-root* quad) (-> (the-as process-taskable s2-0) root trans quad))
|
|
(let ((s4-0 (-> (the-as process-taskable s2-0) node-list data (-> self cam-joint-index) bone transform))
|
|
(s3-0 (-> (the-as process-taskable s2-0) node-list data (-> self cam-joint-index) bone scale))
|
|
(gp-0 (new 'stack-no-clear 'vector))
|
|
(s5-0 (new 'stack-no-clear 'vector))
|
|
(s1-0 (or (!= (-> self spooling?) #t) (logtest? (-> (the-as process-taskable s2-0) skel status) (janim-status spool)))))
|
|
(vector<-cspace! s5-0 (-> (the-as process-taskable s2-0) node-list data (-> self cam-joint-index)))
|
|
(vector-normalize-copy! gp-0 (-> s4-0 vector 2) -1.0)
|
|
(when s1-0
|
|
(when (not (-> self had-valid-frame))
|
|
(set! (-> self had-valid-frame) #t)
|
|
(set! (-> self old-pos quad) (-> s5-0 quad))
|
|
(set! (-> self old-mat-z quad) (-> gp-0 quad)))
|
|
(when #t
|
|
(set! (-> *camera-other-trans* quad) (-> s5-0 quad))
|
|
(vector-normalize-copy! (the-as vector (-> *camera-other-matrix* vector)) (the-as vector (-> s4-0 vector)) -1.0)
|
|
(set! (-> *camera-other-matrix* vector 0 w) 0.0)
|
|
(vector-normalize-copy! (-> *camera-other-matrix* vector 1) (-> s4-0 vector 1) 1.0)
|
|
(set! (-> *camera-other-matrix* vector 1 w) 0.0)
|
|
(vector-normalize-copy! (-> *camera-other-matrix* vector 2) (-> s4-0 vector 2) -1.0)
|
|
(set! (-> *camera-other-matrix* vector 2 w) 0.0)
|
|
(vector-reset! (-> *camera-other-matrix* vector 3))
|
|
(othercam-calc (-> s3-0 x)))
|
|
(set! *camera-look-through-other* 2)
|
|
(set! (-> self old-pos quad) (-> s5-0 quad))
|
|
(set! (-> self old-mat-z quad) (-> gp-0 quad)))))
|
|
(suspend)
|
|
(let ((a0-25 (-> self hand process 0)))
|
|
(when (or (-> self die?) (and (not (-> self survive-anim-end?)) (ja-anim-done? a0-25)))
|
|
(let ((gp-1 (current-time)))
|
|
(while (and (not (time-elapsed? gp-1 (seconds 60)))
|
|
(or (and (-> self entity) (not (is-object-visible? (-> self entity extra level) (-> self entity extra vis-id))))
|
|
(< 81920.0 (vector-vector-distance (camera-pos) (-> *math-camera* trans)))))
|
|
(suspend)))
|
|
(deactivate self))))))
|
|
|
|
(defbehavior othercam-init-by-other othercam ((arg0 process-taskable) (arg1 symbol) (arg2 symbol) (arg3 symbol))
|
|
(set! (-> self spooling?) arg3)
|
|
(case (-> self spooling?)
|
|
(('logo))
|
|
(else (set! (-> *game-info* other-camera-handle) (process->handle self))))
|
|
(set! (-> self hand) (process->handle arg0))
|
|
(set! (-> self cam-joint-index) (the-as int arg1))
|
|
(logclear! (-> self mask) (process-mask pause menu actor-pause))
|
|
(set! (-> self border-value) #f)
|
|
(set! (-> self die?) #f)
|
|
(set! (-> self survive-anim-end?) arg2)
|
|
(set! (-> self mask-to-clear) (process-mask movie enemy platform projectile))
|
|
(set! (-> self event-hook) (-> othercam-running event))
|
|
(go othercam-running)
|
|
0
|
|
(none))
|
|
|
|
(defmethod draw-npc-shadow ((this process-taskable))
|
|
(let ((gp-0 (-> this draw shadow-ctrl)))
|
|
(cond
|
|
((and (-> this draw shadow) (zero? (-> this draw cur-lod)) (logtest? (-> this draw status) (draw-status was-drawn)))
|
|
(collide-to-find-planes gp-0 (-> this draw origin) -4096.0 4096.0 32768.0)
|
|
(update-direction-from-time-of-day gp-0))
|
|
(else (let ((v1-10 gp-0)) (logior! (-> v1-10 settings flags) (shadow-flags disable-draw))) 0)))
|
|
(none))
|