mirror of
https://github.com/open-goal/jak-project
synced 2026-05-27 08:09:29 -04:00
4b8b2abbed
Adds the `pckernel` system to Jak 2, allowing you to do the PC-specific things that Jak 1 lets you do like change game resolution, etc. In other to reduce the amount of code duplication for something that we're gonna be changing a lot over time, I split it into a few more code files. In this new system, `pckernel-h.gc`, `pckernel-common.gc` (previously `pckernel.gc`) and `pc-debug-common.gc` are the files that should be shared across all games (I hacked the Jak 2 project to pull these files from the Jak 1 folder), while `pckernel-impl.gc`, `pckernel.gc` and `pc-debug-methods.gc` are their respective game-specific counterparts that should be loaded after. I'm not fully happy with this, I think it's slightly messy, but it cleanly separates code that should be game-specific and not accidentally copied around and code that should be the same for all games anyway.
457 lines
18 KiB
Common Lisp
Vendored
Generated
457 lines
18 KiB
Common Lisp
Vendored
Generated
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; definition for method 7 of type process-taskable
|
|
;; WARN: Return type mismatch process-focusable vs process-taskable.
|
|
(defmethod relocate process-taskable ((obj process-taskable) (arg0 int))
|
|
(if (nonzero? (-> obj task))
|
|
(&+! (-> obj task) arg0)
|
|
)
|
|
(the-as process-taskable ((method-of-type process-focusable relocate) obj arg0))
|
|
)
|
|
|
|
;; definition for function process-taskable-anim-loop
|
|
;; WARN: Return type mismatch int vs none.
|
|
(defbehavior process-taskable-anim-loop process-taskable ((arg0 (function process-taskable object)))
|
|
"Takes in a function and loops as long as it's return value is truthy
|
|
Seen take in - `true-func` which takes no args TODO - seems fishy
|
|
- a `(process-taskable process) lambda"
|
|
(while (arg0 self)
|
|
(let ((s5-0 (get-art-elem self)))
|
|
(when (!= (ja-group) s5-0)
|
|
(ja-channel-push! 1 0)
|
|
(set! (-> self skel root-channel 0 frame-group) (the-as art-joint-anim s5-0))
|
|
)
|
|
)
|
|
(suspend)
|
|
(if (ja-group)
|
|
(ja :num! (loop!))
|
|
)
|
|
(process-taskable-method-36 self)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
;; definition for method 34 of type process-taskable
|
|
(defmethod process-taskable-method-34 process-taskable ((obj process-taskable))
|
|
#t
|
|
)
|
|
|
|
;; definition for method 35 of type process-taskable
|
|
;; WARN: Return type mismatch art-joint-anim vs art-element.
|
|
(defmethod get-art-elem process-taskable ((obj process-taskable))
|
|
"Checks various things such the current actor, task status, etc to determine the right art-group data to use
|
|
@returns the appropriate [[art-element]] for the given NPC"
|
|
(the-as art-element (if (> (-> obj skel active-channels) 0)
|
|
(-> obj skel root-channel 0 frame-group)
|
|
)
|
|
)
|
|
)
|
|
|
|
;; definition for method 36 of type process-taskable
|
|
;; WARN: Return type mismatch int vs none.
|
|
(defmethod process-taskable-method-36 process-taskable ((obj process-taskable))
|
|
0
|
|
(none)
|
|
)
|
|
|
|
;; definition for method 37 of type process-taskable
|
|
(defmethod process-taskable-method-37 process-taskable ((obj process-taskable))
|
|
(let ((v1-1 (-> obj draw shadow-ctrl)))
|
|
(cond
|
|
((and (-> obj draw shadow)
|
|
(zero? (-> obj draw cur-lod))
|
|
(logtest? (-> obj draw status) (draw-control-status on-screen))
|
|
)
|
|
(shadow-control-method-13 v1-1 (-> obj draw origin) -4096.0 4096.0 32768.0)
|
|
)
|
|
(else
|
|
(logior! (-> v1-1 settings flags) (shadow-flags disable-draw))
|
|
0
|
|
)
|
|
)
|
|
)
|
|
(none)
|
|
)
|
|
|
|
;; failed to figure out what this is:
|
|
(defstate hide (process-taskable)
|
|
:virtual #t
|
|
:event (behavior ((proc process) (arg1 int) (event-type symbol) (event event-message-block))
|
|
(the-as object (case event-type
|
|
(('say)
|
|
(let ((v0-0 (-> self clock frame-counter)))
|
|
(set! (-> self want-to-say) v0-0)
|
|
v0-0
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
:enter (behavior ()
|
|
(set! (-> self state-time) (-> self clock frame-counter))
|
|
(logior! (-> self draw status) (draw-control-status no-draw-bounds))
|
|
(let ((v1-6 (-> self root-override root-prim)))
|
|
(set! (-> v1-6 prim-core collide-as) (collide-spec))
|
|
(set! (-> v1-6 prim-core collide-with) (collide-spec))
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
:exit (behavior ()
|
|
(logclear! (-> self draw status) (draw-control-status no-draw-bounds))
|
|
(let ((v1-3 (-> self root-override root-prim)))
|
|
(set! (-> v1-3 prim-core collide-as) (-> self root-override backup-collide-as))
|
|
(set! (-> v1-3 prim-core collide-with) (-> self root-override backup-collide-with))
|
|
)
|
|
(none)
|
|
)
|
|
:trans (behavior ()
|
|
(let ((v1-1 (get-current-task-event (-> self task))))
|
|
(if (and (nonzero? (-> v1-1 action)) (or (not (logtest? (-> self draw status) (draw-control-status on-screen)))
|
|
(logtest? (-> v1-1 flags) (game-task-flags gatflag-01))
|
|
(< (- (-> self clock frame-counter) (-> self birth-time)) (seconds 0.1))
|
|
)
|
|
)
|
|
(go-virtual idle)
|
|
)
|
|
)
|
|
(none)
|
|
)
|
|
:code (the-as (function none :behavior process-taskable) sleep-code)
|
|
)
|
|
|
|
;; failed to figure out what this is:
|
|
(defstate idle (process-taskable)
|
|
:virtual #t
|
|
:enter (behavior ()
|
|
(set! (-> self state-time) (-> self clock frame-counter))
|
|
(none)
|
|
)
|
|
:exit (behavior ()
|
|
(logclear! (-> self draw status) (draw-control-status no-draw))
|
|
(none)
|
|
)
|
|
:trans (behavior ()
|
|
(let ((gp-0 (get-current-task-event (-> self task))))
|
|
(cond
|
|
((= (-> gp-0 action) (game-task-action hide))
|
|
(if (or (not (logtest? (-> self draw status) (draw-control-status on-screen)))
|
|
(logtest? (-> gp-0 flags) (game-task-flags gatflag-01))
|
|
)
|
|
(go-virtual hide)
|
|
)
|
|
)
|
|
((or (not *target*) *scene-player*)
|
|
)
|
|
((not (-> self will-talk))
|
|
(if (>= (- (-> *display* game-clock frame-counter) (-> self last-talk)) (seconds 5))
|
|
(set! (-> self will-talk) #t)
|
|
)
|
|
)
|
|
((and (-> gp-0 scene)
|
|
(begin
|
|
(if (not (or (demo?)
|
|
(= (-> gp-0 action) (game-task-action play))
|
|
(-> *setting-control* user-current movie-name)
|
|
(name= (-> gp-0 scene) (-> *setting-control* user-current movie-name))
|
|
)
|
|
)
|
|
(gui-control-method-12
|
|
*gui-control*
|
|
self
|
|
(gui-channel art-load)
|
|
(gui-action queue)
|
|
(the-as string (-> gp-0 scene))
|
|
0
|
|
-99.0
|
|
(new 'static 'sound-id)
|
|
)
|
|
)
|
|
(and (zero? (logand (focus-status dead in-air in-head pole flut tube pilot mech dark) (-> *target* focus-status)))
|
|
(and (or (and (< (-> (target-pos 0) y) (+ (-> self root-override root-prim prim-core world-sphere y) (-> self talk-height)))
|
|
(let ((s5-0 (get-trans self 2))
|
|
(f30-0 (if (= (-> gp-0 distance) 0.0)
|
|
(-> self talk-distance)
|
|
(-> gp-0 distance)
|
|
)
|
|
)
|
|
)
|
|
(< (vector-vector-distance (target-pos 0) s5-0) f30-0)
|
|
)
|
|
)
|
|
(< (- (-> self clock frame-counter) (-> self want-to-say)) (seconds 4))
|
|
)
|
|
(or (not (load-in-progress? *level*)) (= (-> gp-0 action) (game-task-action say)))
|
|
(and (not (movie?))
|
|
(not (talker-displayed?))
|
|
(none-reserved? *art-control*)
|
|
(not *progress-process*)
|
|
(not (-> *setting-control* user-current movie))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(when (and (or (= (-> gp-0 action) (game-task-action say))
|
|
(= (-> gp-0 action) (game-task-action talk))
|
|
(= (-> gp-0 action) (game-task-action shade))
|
|
(= (-> gp-0 action) (game-task-action play))
|
|
)
|
|
(process-taskable-method-34 self)
|
|
)
|
|
(when (or (= (-> gp-0 action) (game-task-action say))
|
|
(< (- (-> self clock frame-counter) (-> self want-to-say)) (seconds 4))
|
|
)
|
|
(case (-> gp-0 action)
|
|
(((game-task-action play))
|
|
(go-virtual play-game gp-0)
|
|
)
|
|
(else
|
|
(go-virtual active gp-0)
|
|
)
|
|
)
|
|
)
|
|
(kill-current-talker (the-as symbol '()) '(daxter voicebox ambient) 'exit)
|
|
(talker-surpress!)
|
|
(when (can-display-query? self (the-as string #f) -99.0)
|
|
(let ((s5-1
|
|
(new 'stack 'font-context *font-default-matrix* 32 280 0.0 (font-color default) (font-flags shadow kerning))
|
|
)
|
|
)
|
|
(let ((v1-84 s5-1))
|
|
(set! (-> v1-84 width) (the float 340))
|
|
)
|
|
(let ((v1-85 s5-1))
|
|
(set! (-> v1-85 height) (the float 80))
|
|
)
|
|
(let ((v1-86 s5-1))
|
|
(set! (-> v1-86 scale) 0.9)
|
|
)
|
|
(set! (-> s5-1 flags) (font-flags shadow kerning left large))
|
|
(print-game-text (lookup-text! *common-text* (-> self talk-message) #f) s5-1 #f 44 (bucket-id progress))
|
|
)
|
|
(when (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))
|
|
(case (-> gp-0 action)
|
|
(((game-task-action play))
|
|
(go-virtual play-game gp-0)
|
|
)
|
|
(else
|
|
(go-virtual active gp-0)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(process-taskable-method-37 self)
|
|
(none)
|
|
)
|
|
:code (behavior ()
|
|
(process-taskable-anim-loop (the-as (function process-taskable object) true-func))
|
|
(none)
|
|
)
|
|
:post (behavior ()
|
|
(if (and (-> self hide-during-movie) (movie?))
|
|
(logior! (-> self draw status) (draw-control-status no-draw))
|
|
(logclear! (-> self draw status) (draw-control-status no-draw))
|
|
)
|
|
(when (-> self look-at-me)
|
|
(if *target*
|
|
(look-at! (-> *target* neck) (get-trans self 2) 'nothing-special self)
|
|
)
|
|
)
|
|
(transform-post)
|
|
(none)
|
|
)
|
|
)
|
|
|
|
;; failed to figure out what this is:
|
|
(defstate active (process-taskable)
|
|
:virtual #t
|
|
:event (-> (method-of-type process-taskable hide) event)
|
|
:enter (behavior ((arg0 game-task-event))
|
|
(set! (-> self want-to-say) 0)
|
|
(process-entity-status! self (entity-perm-status no-kill) #t)
|
|
(logclear! (-> self mask) (process-mask actor-pause))
|
|
(none)
|
|
)
|
|
:exit (behavior ()
|
|
(set! (-> self last-talk) (-> *display* game-clock frame-counter))
|
|
(if (< (- (-> self clock frame-counter) (-> self want-to-say)) (seconds 4))
|
|
(set! (-> self will-talk) #t)
|
|
(set! (-> self will-talk) #f)
|
|
)
|
|
(process-entity-status! self (entity-perm-status no-kill) #f)
|
|
(logior! (-> self mask) (process-mask actor-pause))
|
|
(logclear! (-> self draw status) (draw-control-status no-draw))
|
|
(let ((v1-13 (-> self root-override root-prim)))
|
|
(set! (-> v1-13 prim-core collide-as) (-> self root-override backup-collide-as))
|
|
(set! (-> v1-13 prim-core collide-with) (-> self root-override backup-collide-with))
|
|
)
|
|
(none)
|
|
)
|
|
:code (behavior ((arg0 game-task-event))
|
|
(when (-> arg0 scene)
|
|
(let ((gp-1 (ppointer->handle (process-spawn scene-player :init scene-player-init (-> arg0 scene) #t #f))))
|
|
(while (and (handle->process (the-as handle gp-1)) (not (movie?)))
|
|
(suspend)
|
|
)
|
|
(logior! (-> self draw status) (draw-control-status no-draw))
|
|
(let ((v1-17 (-> self root-override root-prim)))
|
|
(set! (-> v1-17 prim-core collide-as) (collide-spec))
|
|
(set! (-> v1-17 prim-core collide-with) (collide-spec))
|
|
)
|
|
0
|
|
(while (handle->process (the-as handle gp-1))
|
|
(suspend)
|
|
)
|
|
)
|
|
)
|
|
(go-virtual hide)
|
|
(none)
|
|
)
|
|
)
|
|
|
|
;; failed to figure out what this is:
|
|
(defstate play-game (process-taskable)
|
|
:virtual #t
|
|
:enter (-> (method-of-type process-taskable active) enter)
|
|
:exit (-> (method-of-type process-taskable active) exit)
|
|
:code (behavior ((arg0 game-task-event))
|
|
(let ((gp-0 (-> self clock frame-counter)))
|
|
(until (>= (- (-> self clock frame-counter) gp-0) (seconds 0.5))
|
|
(suspend)
|
|
)
|
|
)
|
|
(go-virtual hide)
|
|
(none)
|
|
)
|
|
:post (-> (method-of-type process-taskable idle) post)
|
|
)
|
|
|
|
;; definition for method 31 of type process-taskable
|
|
;; WARN: Return type mismatch int vs none.
|
|
(defmethod process-taskable-method-31 process-taskable ((obj process-taskable))
|
|
(let ((s5-0 (new 'process 'collide-shape obj (collide-list-enum usually-hit-by-player))))
|
|
(let ((s4-0 (new 'process 'collide-shape-prim-group s5-0 (the-as uint 3) 0)))
|
|
(set! (-> s5-0 total-prims) (the-as uint 4))
|
|
(set! (-> s4-0 prim-core collide-as) (collide-spec civilian))
|
|
(set! (-> s4-0 prim-core action) (collide-action solid no-standon))
|
|
(set! (-> s4-0 transform-index) 0)
|
|
(set-vector! (-> s4-0 local-sphere) 0.0 -1024.0 0.0 7372.8)
|
|
(set! (-> s5-0 root-prim) s4-0)
|
|
)
|
|
(let ((v1-7 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
|
|
(set! (-> v1-7 prim-core collide-as) (collide-spec civilian))
|
|
(set! (-> v1-7 prim-core action) (collide-action solid))
|
|
(set! (-> v1-7 transform-index) 0)
|
|
(set-vector! (-> v1-7 local-sphere) 0.0 -4096.0 0.0 4096.0)
|
|
)
|
|
(let ((v1-9 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
|
|
(set! (-> v1-9 prim-core collide-as) (collide-spec civilian))
|
|
(set! (-> v1-9 prim-core action) (collide-action solid))
|
|
(set! (-> v1-9 transform-index) 0)
|
|
(set-vector! (-> v1-9 local-sphere) 0.0 -1024.0 0.0 4096.0)
|
|
)
|
|
(let ((v1-11 (new 'process 'collide-shape-prim-sphere s5-0 (the-as uint 0))))
|
|
(set! (-> v1-11 prim-core collide-as) (collide-spec civilian))
|
|
(set! (-> v1-11 prim-core action) (collide-action solid no-standon))
|
|
(set! (-> v1-11 transform-index) 0)
|
|
(set-vector! (-> v1-11 local-sphere) 0.0 2048.0 0.0 4096.0)
|
|
)
|
|
(set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w)))
|
|
(let ((v1-14 (-> s5-0 root-prim)))
|
|
(set! (-> s5-0 backup-collide-as) (-> v1-14 prim-core collide-as))
|
|
(set! (-> s5-0 backup-collide-with) (-> v1-14 prim-core collide-with))
|
|
)
|
|
(set! (-> obj root-override) s5-0)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
;; definition for method 32 of type process-taskable
|
|
;; WARN: Return type mismatch int vs none.
|
|
(defmethod process-taskable-method-32 process-taskable ((obj process-taskable))
|
|
(logior! (-> obj skel status) (joint-control-status eye-anim))
|
|
(set! (-> obj talk-message) (game-text-id text-x181))
|
|
(set! (-> obj bounce-away) #t)
|
|
(set! (-> obj will-talk) #t)
|
|
(set! (-> obj look-at-me) #t)
|
|
(set! (-> obj hide-during-movie) #t)
|
|
(set! (-> obj neck-joint-index) -1)
|
|
(set! (-> obj talk-distance) (res-lump-float (-> obj entity) 'distance :default 32768.0))
|
|
(set! (-> obj talk-height) (res-lump-float (-> obj entity) 'height :default 8192.0))
|
|
(set! (-> obj slave) (the-as handle #f))
|
|
(set! (-> obj draw shadow-ctrl)
|
|
(new 'process 'shadow-control 0.0 0.0 614400.0 (shadow-flags shdf02 shdf03 shdf04 disable-draw) 245760.0)
|
|
)
|
|
(let ((s5-0 0))
|
|
(let ((v1-15 (the-as joint (get-art-by-name-method (-> obj draw jgeo) "main" (the-as type #f)))))
|
|
(if v1-15
|
|
(set! s5-0 (+ (-> v1-15 number) 1))
|
|
)
|
|
)
|
|
(let ((v1-19 (the-as collide-shape-prim-group (-> obj root-override root-prim))))
|
|
(set! (-> v1-19 transform-index) s5-0)
|
|
(dotimes (a0-7 (the-as int (-> v1-19 num-children)))
|
|
(set! (-> v1-19 child a0-7 transform-index) s5-0)
|
|
)
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
;; definition for method 33 of type process-taskable
|
|
;; WARN: Return type mismatch int vs none.
|
|
(defmethod init-art! process-taskable ((obj process-taskable))
|
|
"@see [[initialize-skeleton]]"
|
|
0
|
|
(none)
|
|
)
|
|
|
|
;; definition for method 11 of type process-taskable
|
|
;; WARN: Return type mismatch object vs none.
|
|
(defmethod init-from-entity! process-taskable ((obj process-taskable) (arg0 entity-actor))
|
|
"Typically the method that does the initial setup on the process, potentially using the [[entity-actor]] provided as part of that.
|
|
This commonly includes things such as:
|
|
- stack size
|
|
- collision information
|
|
- loading the skeleton group / bones
|
|
- sounds"
|
|
(stack-size-set! (-> obj main-thread) 512)
|
|
(process-taskable-method-31 obj)
|
|
(process-drawable-from-entity! obj arg0)
|
|
(set! (-> obj task)
|
|
(new 'process 'game-task-control (res-lump-value arg0 'task-actor game-task-actor :time -1000000000.0))
|
|
)
|
|
(init-art! obj)
|
|
(process-taskable-method-32 obj)
|
|
(when (logtest? #x1000000 (res-lump-value arg0 'options uint128 :time -1000000000.0))
|
|
(let* ((s5-1 *level*)
|
|
(s4-2 (method-of-object s5-1 art-group-get-by-name))
|
|
)
|
|
(format (clear *temp-string*) "skel-~S" (-> obj draw art-group name))
|
|
(let ((s4-3 (s4-2 s5-1 *temp-string* (the-as (pointer uint32) #f))))
|
|
(when s4-3
|
|
(let ((s5-2 (process-spawn manipy :init manipy-init (-> obj root-override trans) (-> obj entity) s4-3 #f 0 :to obj))
|
|
)
|
|
(send-event (ppointer->process s5-2) 'anim-mode 'mirror)
|
|
(send-event (ppointer->process s5-2) 'mirror #t)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(set! (-> obj event-hook) (-> (method-of-object obj idle) event))
|
|
(go (method-of-object obj hide))
|
|
(none)
|
|
)
|