From 7c5c7003b308fd04d6054e47fd7051486f80d94d Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Sat, 11 Jun 2022 21:52:19 +0100 Subject: [PATCH] minor fixes to pc goal code (#1442) * sound fixes especially for inf eco * minor cleanup * blue eco fixes --- .../anonymous_function_types.jsonc | 2 +- goal_src/engine/game/game-info.gc | 1295 ++++++++--------- goal_src/engine/sound/gsound.gc | 45 +- goal_src/pc/hud-classes-pc.gc | 2 +- goal_src/pc/pckernel.gc | 52 +- .../reference/engine/game/game-info_REF.gc | 4 +- 6 files changed, 650 insertions(+), 750 deletions(-) diff --git a/decompiler/config/jak1_ntsc_black_label/anonymous_function_types.jsonc b/decompiler/config/jak1_ntsc_black_label/anonymous_function_types.jsonc index 9e456e0301..ce9fd6224c 100644 --- a/decompiler/config/jak1_ntsc_black_label/anonymous_function_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/anonymous_function_types.jsonc @@ -506,7 +506,7 @@ ], "game-info": [ - [17, "(function symbol symbol continue-point symbol none)"], + [17, "(function symbol symbol continue-point game-save none)"], [6, "(function process-drawable none)"], [7, "(function none :behavior process-drawable)"], [8, "(function object)"] diff --git a/goal_src/engine/game/game-info.gc b/goal_src/engine/game/game-info.gc index a534efe216..1317ffff94 100644 --- a/goal_src/engine/game/game-info.gc +++ b/goal_src/engine/game/game-info.gc @@ -20,17 +20,17 @@ (defmethod debug-draw! border-plane ((obj border-plane)) "Debug draw a border plane with a vector and text." (let* ((v1-0 (-> obj action)) - ;; pick color based on action + ;; pick color based on action (s5-0 (if (= v1-0 'load) (new 'static 'rgba :g #xff :a #x80) (new 'static 'rgba :r #xff :a #x80) ) - ) + ) ) ;; add text and vector (add-debug-text-sphere #t (bucket-id debug-no-zbuf) (-> obj trans) 819.2 (symbol->string (-> obj name)) s5-0) - (add-debug-vector #t (bucket-id debug-no-zbuf) (-> obj trans) (-> obj normal) 8192.0 s5-0) + (add-debug-vector #t (bucket-id debug-no-zbuf) (-> obj trans) (-> obj normal) (meters 2.0) s5-0) ) 0 (none) @@ -39,10 +39,7 @@ (defmethod point-past-plane? border-plane ((obj border-plane) (arg0 vector)) "Which side of the plane is the given point on? #t = on the plane, or on the side the normal points toward." - (>= (vector-dot - (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj trans)) - (-> obj normal)) - 0.0) + (>= (vector-dot (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj trans)) (-> obj normal)) 0.0) ) (defmethod task-complete? game-info ((obj game-info) (arg0 game-task)) @@ -51,21 +48,20 @@ ) ;; set up a static continue point that can be used as a temporary continue point. -(define *default-continue* - (new 'static 'continue-point - :name "default" - :level #f - :trans (new 'static 'vector :w 1.0) - :quat (new 'static 'quaternion :w 1.0) - :camera-trans (new 'static 'vector :w 1.0) - :load-commands '() - :vis-nick #f - :lev0 #f - :disp0 #f - :lev1 #f - :disp1 #f - ) - ) +(define *default-continue* (new 'static 'continue-point + :name "default" + :level #f + :trans (new 'static 'vector :w 1.0) + :quat (new 'static 'quaternion :w 1.0) + :camera-trans (new 'static 'vector :w 1.0) + :load-commands '() + :vis-nick #f + :lev0 #f + :disp0 #f + :lev1 #f + :disp1 #f + ) + ) (defmethod get-or-create-continue! game-info ((obj game-info)) "Attempt to get a continue point, if it doesn't exist set the @@ -100,9 +96,9 @@ ;; loop over continues in the level (while (not (null? s4-0)) (let ((s3-0 (car s4-0))) - (if (string= arg0 (the-as string (-> (the-as continue-point s3-0) name))) + (if (string= arg0 (-> (the-as continue-point s3-0) name)) ;; match! - (return (the continue-point s3-0)) + (return (the-as continue-point s3-0)) ) ) (set! s4-0 (cdr s4-0)) @@ -115,7 +111,7 @@ ) (defmethod set-continue! game-info ((obj game-info) (arg0 basic)) - "Set the current continue to to arg0. + "Set the current continue point to to arg0. arg0 can be: '() or #f, in which case it does nothing. a string, in which case it looks up by name @@ -130,34 +126,28 @@ (if (null? arg0) (set! arg0 #f) ) - (let ((v1-3 (-> arg0 type))) - (cond - ((= v1-3 string) - (let ((v1-5 (get-continue-by-name obj (the-as string arg0)))) - (if v1-5 - (set! (-> obj current-continue) v1-5) - ) - ) - ) - (else - (cond - ((= v1-3 continue-point) - (set! (-> obj current-continue) (the-as continue-point arg0)) - ) - (else - (let ((s4-3 *default-continue*)) - (position-in-front-of-camera! (-> s4-3 trans) 40960.0 4096.0) - (quaternion-identity! (-> s4-3 quat)) - (set! (-> s4-3 vis-nick) (-> *load-state* vis-nick)) - (set! (-> s4-3 lev0) (-> *load-state* want 0 name)) - (set! (-> s4-3 disp0) (-> *load-state* want 0 display?)) - (set! (-> s4-3 lev1) (-> *load-state* want 1 name)) - (set! (-> s4-3 disp1) (-> *load-state* want 1 display?)) - (set! (-> obj current-continue) s4-3) - ) - ) - ) + (case (-> arg0 type) + ((string) + (let ((v1-5 (get-continue-by-name obj (the-as string arg0)))) + (if v1-5 + (set! (-> obj current-continue) v1-5) + ) ) + ) + ((continue-point) + (set! (-> obj current-continue) (the-as continue-point arg0)) + ) + (else + (let ((s4-3 *default-continue*)) + (position-in-front-of-camera! (-> s4-3 trans) 40960.0 4096.0) + (quaternion-identity! (-> s4-3 quat)) + (set! (-> s4-3 vis-nick) (-> *load-state* vis-nick)) + (set! (-> s4-3 lev0) (-> *load-state* want 0 name)) + (set! (-> s4-3 disp0) (-> *load-state* want 0 display?)) + (set! (-> s4-3 lev1) (-> *load-state* want 1 name)) + (set! (-> s4-3 disp1) (-> *load-state* want 1 display?)) + (set! (-> obj current-continue) s4-3) + ) ) ) (when (!= s5-0 (-> obj current-continue)) @@ -174,125 +164,114 @@ ) (defmethod initialize! game-info ((obj game-info) (cause symbol) (save-to-load game-save) (continue-point-override string)) - "Initialize the game-info. + "Initialize the game-info. The cause can be 'dead if you die, or 'game to reset everything. If save-to-load is not #f will load data from that. If continue-point-override is not #f, will use that." - + (local-vars (v0-0 int) (sv-96 symbol)) - (let ((selected-cause cause)) - (when (= selected-cause 'dead) - ;; reload game-info because we died. Increase death counts - (set! (-> obj total-deaths) (+ (-> obj total-deaths) 1)) - (set! (-> obj continue-deaths) (+ (-> obj continue-deaths) 1)) - (set! (-> obj fuel-cell-deaths) (+ (-> obj fuel-cell-deaths) 1)) - (when *target* - (let ((lev-info (-> *target* current-level info))) - (when (>= (-> *level-task-data-remap* length) (-> lev-info index)) - ;; update death per level. - (set! v0-0 - (seekl - (the-as int (-> obj deaths-per-level (-> *level-task-data-remap* (+ (-> lev-info index) -1)))) - 255 - 1 - ) - ) - (set! (-> obj deaths-per-level (-> *level-task-data-remap* (+ (-> lev-info index) -1))) (the-as uint v0-0)) - ) - ) - ) - - (let ((v1-27 (-> obj mode))) - (cond - ((= v1-27 'play) - ;; now pick between life/try depending on if we ran out of lives or not. - (if (< 0.0 (-> obj life)) - (set! cause 'life) - (set! cause 'try) - ) - ) - (else - ;; not in play mode, we're done. - (begin - (set! obj obj) - (goto cfg-50) - ) - ) - ) - ) - ) - ) - - ;; ? - (kill-current-level-hint '() '() 'die) - - (let ((v1-31 cause)) - (when (= v1-31 'game) - ;; we are doing a full restart. - ;; reset everything! - (reset-all-hint-controls) - (set-continue! obj - (cond - (continue-point-override - continue-point-override - ) - ((!= *kernel-boot-message* 'play) - "demo-start" - ) - (*debug-segment* - "village1-hut" - ) - (else - "title-start" - ) + (case cause + (('dead) + ;; reload game-info because we died. Increase death counts + (+! (-> obj total-deaths) 1) + (+! (-> obj continue-deaths) 1) + (+! (-> obj fuel-cell-deaths) 1) + (when *target* + (let ((lev-info (-> *target* current-level info))) + (set! v0-0 + (when (>= (-> *level-task-data-remap* length) (-> lev-info index)) + ;; update death per level. + (set! v0-0 + (seekl (the-as int (-> obj deaths-per-level (-> *level-task-data-remap* (+ (-> lev-info index) -1)))) 255 1) ) - ) - (set! (-> obj auto-save-count) 0) - (set! (-> *setting-control* default auto-save) #f) - (set! (-> obj money) 0.0) - (set! (-> obj fuel) 0.0) - (set! (-> obj money-total) 0.0) - (set! (-> obj buzzer-total) 0.0) - (set! (-> obj perm-list length) 0) - (clear-all! (-> obj text-ids-seen)) - (set! (-> obj death-movie-tick) (rand-vu-int-count 10)) - (set! (-> obj total-deaths) 0) - (set! (-> obj continue-deaths) 0) - (set! (-> obj fuel-cell-deaths) 0) - (set! (-> obj death-pos length) 0) - (set! (-> obj game-start-time) (-> *display* base-frame-counter)) - (set! (-> obj fuel-cell-pickup-time) (-> *display* base-frame-counter)) - (set! (-> obj continue-time) (-> *display* base-frame-counter)) - (set! (-> obj death-time) (-> *display* base-frame-counter)) - (set! (-> obj hit-time) (-> *display* base-frame-counter)) - (dotimes (v1-50 116) - (set! (-> obj fuel-cell-time 0) 0) - (nop!) + (set! (-> obj deaths-per-level (-> *level-task-data-remap* (+ (-> lev-info index) -1))) (the-as uint v0-0)) + v0-0 + ) + ) + ) + ) + (case (-> obj mode) + (('play) + ;; now pick between life/try depending on if we ran out of lives or not. (this isnt really used) + (if (< 0.0 (-> obj life)) + (set! cause 'life) + (set! cause 'try) + ) ) - (dotimes (v1-53 32) - (set! (-> obj money-per-level v1-53) 0) - (set! (-> obj deaths-per-level v1-53) 0) - (set! (-> obj enter-level-time v1-53) 0) - (set! (-> obj in-level-time v1-53) 0) - (set! (-> obj level-opened v1-53) 0) - (nop!) - ) - ) + (else + ;; not in play mode, we're done. + (set! obj obj) + (goto cfg-50) + ) + ) + ) ) - - (let ((v1-56 cause)) - (when (or (= v1-56 'game) (= v1-56 'try)) - ;; full restart, or ran out of lives - (let ((v1-59 (-> obj mode))) - (when (= v1-59 'play) - (set! *display-profile* #f) - (set! *display-entity-errors* #f) - ) + (kill-current-level-hint '() '() 'die) + (case cause + (('game) + ;; we are doing a full restart. + ;; reset everything! + (reset-all-hint-controls) + (set-continue! obj (cond + (continue-point-override + (empty) + continue-point-override + ) + ((!= *kernel-boot-message* 'play) + "demo-start" + ) + (*debug-segment* + "village1-hut" + ) + (else + "title-start" + ) + ) + ) + (set! (-> obj auto-save-count) 0) + (set! (-> *setting-control* default auto-save) #f) + (set! (-> obj money) 0.0) + (set! (-> obj fuel) 0.0) + (set! (-> obj money-total) 0.0) + (set! (-> obj buzzer-total) 0.0) + (set! (-> obj perm-list length) 0) + (clear-all! (-> obj text-ids-seen)) + (set! (-> obj death-movie-tick) (rand-vu-int-count 10)) + (set! (-> obj total-deaths) 0) + (set! (-> obj continue-deaths) 0) + (set! (-> obj fuel-cell-deaths) 0) + (set! (-> obj death-pos length) 0) + (set! (-> obj game-start-time) (-> *display* base-frame-counter)) + (set! (-> obj fuel-cell-pickup-time) (-> *display* base-frame-counter)) + (set! (-> obj continue-time) (-> *display* base-frame-counter)) + (set! (-> obj death-time) (-> *display* base-frame-counter)) + (set! (-> obj hit-time) (-> *display* base-frame-counter)) + (dotimes (v1-50 116) + (set! (-> obj fuel-cell-time 0) 0) + (nop!) + ) + (dotimes (v1-53 32) + (set! (-> obj money-per-level v1-53) (the-as uint 0)) + (set! (-> obj deaths-per-level v1-53) (the-as uint 0)) + (set! (-> obj enter-level-time v1-53) 0) + (set! (-> obj in-level-time v1-53) 0) + (set! (-> obj level-opened v1-53) (the-as uint 0)) + (nop!) + ) + ) + ) + (case cause + (('game 'try) + ;; full restart, or ran out of lives + (case (-> obj mode) + (('play) + (set! *display-profile* #f) + (set! *display-entity-errors* #f) ) - ;; reset lives to default. - (set! (-> obj life-max) (-> *GAME-bank* life-max-default)) - (set! (-> obj life) (-> *GAME-bank* life-start-default)) - ) + ) + (set! (-> obj life-max) (-> *GAME-bank* life-max-default)) + (set! (-> obj life) (-> *GAME-bank* life-start-default)) + ) ) (let ((v1-65 (-> obj mode))) @@ -319,35 +298,26 @@ (set! (-> *level* border?) #f) (set! (-> *setting-control* default border-mode) #f) (set! *spawn-actors* #f) - (set-blackout-frames 30) + (set-blackout-frames (seconds 0.1)) ;; send target a 'reset message. (send-event *target* 'reset) - ;; start a temporary process to restart things - (let ((proc (get-process *4k-dead-pool* process #x4000))) - (when proc - (activate proc *default-pool* 'process *scratch-memory-top*) - (run-next-time-in-process - proc - (lambda ((stop-arg symbol) (reset-arg symbol) (c continue-point) (load game-save)) - (stop stop-arg) - (reset-actors reset-arg) - (set-continue! *game-info* c) - (when load - (load-game! *game-info* load) - (set! c (get-or-create-continue! *game-info*)) - ) - (suspend) - (start stop-arg c) - ) - (-> obj mode) ;; play, debug - cause - (get-or-create-continue! obj) - save-to-load - ) - ) - ) + (process-spawn-function process (lambda ((arg0 symbol) (arg1 symbol) (arg2 continue-point) (arg3 game-save)) + (stop arg0) + (reset-actors arg1) + (set-continue! *game-info* arg2) + (when arg3 + (load-game! *game-info* arg3) + (set! arg2 (get-or-create-continue! *game-info*)) + ) + (suspend) + (start arg0 arg2) + (none) + ) + (-> obj mode) cause (get-or-create-continue! obj) save-to-load + :from *4k-dead-pool* + ) (set-master-mode 'game) ) ) @@ -359,126 +329,119 @@ (defmethod adjust game-info ((obj game-info) (item symbol) (amount float) (source handle)) "Adjust the number of items by amount." - (let ((v1-0 item)) - (cond - ((= v1-0 'life) - ;; get/lose a life, just modify the life field - (if (>= amount 0.0) - (set! (-> obj life) (seek (-> obj life) (-> obj life-max) amount)) - (set! (-> obj life) (seek (-> obj life) 0.0 (- amount))) - ) - (-> obj life) - ) - - ((= v1-0 'money) - (if (and (< 0.0 amount) (= (+ (-> obj money) amount) (-> *GAME-bank* money-task-inc))) - ;; got enough orbs to trade, display a hint - (level-hint-spawn (game-text-id MISSING-orb-hint) "sksp0014" (the entity #f) *entity-pool* (game-task none)) - ) - - ;; need to update the various orb counters - (when (< 0.0 amount) - (let ((proc (handle->process source))) - (when (and proc (-> proc entity)) - ;; we have task data for this level! - (when (>= (-> *level-task-data-remap* length) (-> proc entity extra level info index)) - ;; get the level index - (let ((level-idx (-> *level-task-data-remap* (+ (-> proc entity extra level info index) -1)))) - ;; increment the level money count - (set! (-> obj money-per-level level-idx) (+ (-> obj money-per-level level-idx) (the-as uint (the int amount)))) - ;; increment our total money in the game (out of the 2000 max orbs) - (set! (-> obj money-total) (+ (-> obj money-total) amount)) - ;; if we have all the money in our level, display the all orbs graphic - (if (= (-> obj money-per-level level-idx) (-> (get-game-count level-idx) money-count)) - (activate-orb-all level-idx) - ) - ) - ) - ) + (case item + (('life) + ;; get/lose a life, just modify the life field + (if (>= amount 0.0) + (seek! (-> obj life) (-> obj life-max) amount) + (seek! (-> obj life) 0.0 (- amount)) + ) + (-> obj life) + ) + (('money) + (if (and (< 0.0 amount) (= (+ (-> obj money) amount) (-> *GAME-bank* money-task-inc))) + ;; got enough orbs to trade, display a hint + (level-hint-spawn + (game-text-id MISSING-orb-hint) + "sksp0014" + (the-as entity #f) + *entity-pool* + (game-task none) ) ) - ;; increment our current money count - (let ((f0-18 (+ (-> obj money) amount))) - (set! (-> obj money) f0-18) - f0-18 - ) - ) - - ((= v1-0 'fuel-cell) - ;; got a power cell! - ;; in this case, the amount is actually the index of the power cell's task - (let ((s5-1 (the int amount))) - (when (not (or (task-complete? obj (the-as game-task s5-1)) - (>= (the-as uint 1) (the-as uint s5-1)) - ) - ) - ;; the cell corresponds to a valid and previously incomplete task. - ;; update our stats - (set! (-> obj fuel-cell-deaths) 0) - (set! (-> obj fuel-cell-pickup-time) (-> *display* base-frame-counter)) - (set! (-> obj fuel-cell-time s5-1) (-> *display* base-frame-counter)) - ;; increment power cells! - (set! (-> obj fuel) (+ 1.0 (-> obj fuel))) - ;; mark as completed - (logior! (-> obj task-perm-list data s5-1 status) (entity-perm-status real-complete)) - ;; unused. - (get-task-control (the game-task s5-1)) - ;; close the task! - (close-specific-task! (the-as game-task s5-1) (task-status need-resolution)) - ) - ) - (-> obj fuel) - ) - - ((= v1-0 'buzzer) - ;; got a scout fly. In this case, the amount is actually two 16 bit numbers - ;; the lower 16 bits are the task, and the upper is why fly - (let ((buzz-task (logand (the int amount) #xffff)) - (buzz-index (sar (the int amount) 16)) - (buzz-count 0.0) - ) - (when (> (the-as uint buzz-task) 0) - ;; valid task - (let* ((ctrl (get-task-control (the game-task buzz-task))) - (buzz-bits (get-reminder ctrl 0)) ;; the currently collected flies - ) - (when (and (>= buzz-index 0) - (< buzz-index (the int (-> *FACT-bank* buzzer-max-default))) - ) - ;; valid fly index - - ;; increment total if we haven't collected it before - (if (zero? (logand buzz-bits (ash 1 buzz-index))) - (set! (-> obj buzzer-total) (+ 1.0 (-> obj buzzer-total))) - ) - - ;; set the updated bits - (let ((t9-10 (method-of-object ctrl save-reminder))) - (set! buzz-bits (logior buzz-bits (ash 1 buzz-index))) - (t9-10 ctrl buzz-bits 0) - ) - ) - - ;; recompute the total count - (countdown (v1-58 (the int (-> *FACT-bank* buzzer-max-default))) - (if (nonzero? (logand buzz-bits (ash 1 v1-58))) - (set! buzz-count (+ 1.0 buzz-count)) + ;; need to update the various orb counters + (when (< 0.0 amount) + (let ((proc (handle->process source))) + (when (and proc (-> proc entity)) + ;; we have task data for this level! + (when (>= (-> *level-task-data-remap* length) (-> proc entity extra level info index)) + ;; get the level index + (let ((level-idx (-> *level-task-data-remap* (+ (-> proc entity extra level info index) -1)))) + ;; increment the level money count + (+! (-> obj money-per-level level-idx) (the int amount)) + ;; increment our total money in the game (out of the 2000 max orbs) + (+! (-> obj money-total) amount) + ;; if we have all the money in our level, display the all orbs graphic + (if (= (-> obj money-per-level level-idx) (-> (get-game-count level-idx) money-count)) + (activate-orb-all level-idx) ) ) ) ) - buzz-count ) ) - ) + + ;; increment our current money count + (+! (-> obj money) amount) + ) + (('fuel-cell) + ;; got a power cell! + ;; in this case, the amount is actually the index of the power cell's task + (let ((s5-1 (the int amount))) + (when (not (or (task-complete? obj (the-as game-task s5-1)) (>= (the-as uint 1) (the-as uint s5-1)))) + ;; the cell corresponds to a valid and previously incomplete task. + ;; update our stats + (set! (-> obj fuel-cell-deaths) 0) + (set! (-> obj fuel-cell-pickup-time) (-> *display* base-frame-counter)) + (set! (-> obj fuel-cell-time s5-1) (-> *display* base-frame-counter)) + ;; increment power cells! + (set! (-> obj fuel) (+ 1.0 (-> obj fuel))) + ;; mark as completed + (logior! (-> obj task-perm-list data s5-1 status) (entity-perm-status real-complete)) + ;; unused. + (get-task-control (the-as game-task s5-1)) + ;; close the task! + (close-specific-task! (the-as game-task s5-1) (task-status need-resolution)) + ) + ) + (-> obj fuel) + ) + (('buzzer) + ;; got a scout fly. In this case, the amount is actually two 16 bit numbers + ;; the lower 16 bits are the task, and the upper is which buzzer + (let ((buzz-task (logand (the int amount) #xffff)) + (buzz-index (sar (the int amount) 16)) + (buzz-count 0.0) + ) + (when (> (the-as uint buzz-task) 0) + ;; valid task + (let* ((ctrl (get-task-control (the-as game-task buzz-task))) + (buzz-bits (get-reminder ctrl 0)) ;; the currently collected flies + ) + (when (and (>= buzz-index 0) (< buzz-index (the int (-> *FACT-bank* buzzer-max-default)))) + ;; valid fly index + + ;; increment total if we haven't collected it before + (if (zero? (logand buzz-bits (ash 1 buzz-index))) + (set! (-> obj buzzer-total) (+ 1.0 (-> obj buzzer-total))) + ) + + ;; set the updated bits + (let ((t9-10 (method-of-object ctrl save-reminder))) + (set! buzz-bits (logior buzz-bits (ash 1 buzz-index))) + (t9-10 ctrl buzz-bits 0) + ) + ) + + ;; recompute the total count + (countdown (v1-58 (the int (-> *FACT-bank* buzzer-max-default))) + (if (logtest? buzz-bits (ash 1 v1-58)) + (set! buzz-count (+ 1.0 buzz-count)) + ) + ) + ) + ) + buzz-count + ) + ) ) ) (defmethod got-buzzer? game-info ((obj game-info) (arg0 game-task) (arg1 int)) "Do we have the arg1-th buzzer for the given buzzer task?" ;; buzzers mis-use their reminder bits as a bitfield of which ones have been collected - (nonzero? (logand (get-reminder (get-task-control arg0) 0) (ash 1 arg1))) + (logtest? (get-reminder (get-task-control arg0) 0) (ash 1 arg1)) ) (defmethod buzzer-count game-info ((obj game-info) (arg0 game-task)) @@ -487,7 +450,7 @@ (v0-2 0) ;; count ) (countdown (a0-4 (the int (-> *FACT-bank* buzzer-max-default))) - (if (nonzero? (logand v1-1 (ash 1 a0-4))) + (if (logtest? v1-1 (ash 1 a0-4)) (+! v0-2 1) ) ) @@ -505,37 +468,39 @@ (defmethod mark-text-as-seen game-info ((obj game-info) (arg0 game-text-id)) "Mark the game text as seen. This only works if the text id < 4096, and ignores otherwise" (if (and (< (the-as uint arg0) (the-as uint 4095)) (> (the-as uint arg0) 0)) - (set-bit (-> obj text-ids-seen) (the-as int arg0)) - ) + (set-bit (-> obj text-ids-seen) (the-as int arg0)) + ) + 0 (none) ) (defmethod clear-text-seen! game-info ((obj game-info) (arg0 game-text-id)) "Mark text as unseen. MUST be a valid text id" (clear-bit (-> obj text-ids-seen) (the-as int arg0)) + 0 (none) ) (defmethod reset! fact-info-target ((obj fact-info-target) (arg0 symbol)) "Reset the facts for a given thing" (when (or (not arg0) (= arg0 'eco)) - (set! (-> obj eco-timeout) 0) - (set! (-> obj eco-level) 0.0) - (set! (-> obj eco-pickup-time) (-> *display* game-frame-counter)) - ) + (set! (-> obj eco-timeout) 0) + (set! (-> obj eco-level) 0.0) + (set! (-> obj eco-pickup-time) (-> *display* game-frame-counter)) + ) (when (or (not arg0) (= arg0 'health)) - (set! (-> obj health-max) (-> *FACT-bank* health-max-default)) - (set! (-> obj health) (-> obj health-max)) - (set! (-> obj health-pickup-time) (seconds -100)) - ) + (set! (-> obj health-max) (-> *FACT-bank* health-max-default)) + (set! (-> obj health) (-> obj health-max)) + (set! (-> obj health-pickup-time) (seconds -100)) + ) (when (or (not arg0) (= arg0 'buzzer)) - (set! (-> obj buzzer-max) (-> *FACT-bank* buzzer-max-default)) - (set! (-> obj buzzer) 0.0) - ) + (set! (-> obj buzzer-max) (-> *FACT-bank* buzzer-max-default)) + (set! (-> obj buzzer) 0.0) + ) (when (or (not arg0) (= arg0 'eco-pill)) - (set! (-> obj eco-pill-max) (-> *FACT-bank* eco-pill-max-default)) - (set! (-> obj eco-pill) 0.0) - ) + (set! (-> obj eco-pill-max) (-> *FACT-bank* eco-pill-max-default)) + (set! (-> obj eco-pill) 0.0) + ) (none) ) @@ -543,317 +508,272 @@ (defmethod pickup-collectable! fact-info-target ((obj fact-info-target) (kind pickup-type) (amount float) (source-handle handle)) "Pickup a thing!" - (with-pp - (case kind - (((pickup-type eco-green)) - ;; big green eco. This counts toward the health (up to 3), and if that's full, maxes out the little green ecos to 50. - (cond - ((>= amount 0.0) - ;; got a positive or 0 amount. - (when (< 0.0 amount) - ;; when we get a different source, OR we it's been more than 0.5 seconds since we last got eco - ;; from this source. - (if (or (!= (handle->process source-handle) (handle->process (-> obj eco-source))) - (>= (- (-> *display* base-frame-counter) (-> obj eco-source-time)) (seconds 0.5)) - ) - - ;; play the sound! - (sound-play-by-name (static-sound-name "get-green-eco") - (new-sound-id) - 1024 - 0 - 0 - 1 - #t - ) - ) - - ;; remember the source. - (when (handle->process source-handle) - (set! (-> obj eco-source) source-handle) - (set! (-> obj eco-source-time) (-> *display* base-frame-counter)) + (case kind + (((pickup-type eco-green)) + ;; big green eco. This counts toward the health (up to 3), and if that's full, maxes out the little green ecos to 50. + (cond + ((>= amount 0.0) + ;; got a positive or 0 amount. + (when (< 0.0 amount) + ;; when we get a different source, OR we it's been more than 0.5 seconds since we last got eco + ;; from this source. + (if (or (!= (handle->process source-handle) (handle->process (-> obj eco-source))) + (>= (- (-> *display* base-frame-counter) (-> obj eco-source-time)) (seconds 0.5)) ) - ) - - ;; if we are at max health (3), and collect additional an additional big green eco, - ;; then max out the little green ecos. - (if (= (-> obj health) (-> obj health-max)) - (pickup-collectable! - obj - (pickup-type eco-pill) - (-> *FACT-bank* eco-pill-max-default) - (process->handle (-> obj process)) - ) - ) - - ;; remember when - (set! (-> obj health-pickup-time) (-> *display* base-frame-counter)) - ;; increase the health! - (set! (-> obj health) (seek (-> obj health) (-> obj health-max) amount)) + + ;; play the sound! + (sound-play-by-name (static-sound-name "get-green-eco") (new-sound-id) 1024 0 0 1 #t) ) - (else - ;; negative health. Subtract. - (set! (-> obj health) (seek (-> obj health) 0.0 (- amount))) - - ;; not sure why we do this. But this will set the eco pill collection time. - (if (>= amount -10.0) - (pickup-collectable! obj (pickup-type eco-pill) 0.0 source-handle) - ) - - ;; subtract lives. - (if (= (-> obj health) 0.0) - (adjust - (-> (the-as target (-> obj process)) game) - 'life - (- (-> *GAME-bank* life-single-inc)) - source-handle - ) - ) - ) - ) - - ;; some sort of hack for eco vents. - (b! (and (logtest? (-> (the-as collide-shape (-> obj process root)) root-prim prim-core action) 512) - (type-type? (-> (handle->process source-handle) type) vent) - ) - cfg-80) - (-> obj health) - ) - - (((pickup-type eco-pill)) - ;; collect small green eco - (when (>= amount 0.0) - ;; update small eco count - (set! (-> obj eco-pill-pickup-time) (-> *display* base-frame-counter)) - (set! (-> obj eco-pill) (seek (-> obj eco-pill) (-> obj eco-pill-max) amount)) - - ;; increment big health if needed - (when (and (>= (-> obj eco-pill) (-> *FACT-bank* eco-pill-max-default)) ;; have enough smalls - (< (-> obj health) (-> obj health-max)) ;; and enough room for another health - ) - ;; decrease eco pills - (set! (-> obj eco-pill) - (- (-> obj eco-pill) (-> *FACT-bank* eco-pill-max-default)) - ) - ;; get a big health. - (pickup-collectable! - obj - (pickup-type eco-green) - (-> *FACT-bank* health-small-inc) - (process->handle (-> obj process)) - ) - ) - ) - (-> obj eco-pill) - ) - - (((pickup-type money)) - ;; get money. - (when (< 0.0 amount) - ;; play sound. - (if (>= (- (-> *display* base-frame-counter) (-> obj money-pickup-time)) (seconds 0.05)) - (sound-play-by-name (static-sound-name "money-pickup") - (new-sound-id) - 1024 - 0 - 0 - 1 - #t - ) - ) - (set! (-> obj money-pickup-time) (-> *display* base-frame-counter)) - ) - (adjust (-> (the-as target (-> obj process)) game) - 'money - amount - source-handle - ) - ) - (((pickup-type fuel-cell)) - ;; the amount is actually the index of the task. - (let ((s4-2 (the int amount))) - (if (not (or (task-complete? (-> (the-as target (-> obj process)) game) (the-as game-task s4-2) ) - (>= (the-as uint 1) (the-as uint s4-2)) - ) - ) - (set! (-> obj fuel-cell-pickup-time) (-> *display* base-frame-counter)) - ) - ) - (adjust - (-> (the-as target (-> obj process)) game) - 'fuel-cell - amount - source-handle - ) - ) - (((pickup-type buzzer)) - ;; scout fly. - (let ((buzz-count (adjust - (-> (the-as target (-> obj process)) game) - 'buzzer - amount - source-handle - ) - ) - ) - (if (!= buzz-count (-> obj buzzer)) - (set! (-> obj buzzer-pickup-time) (-> *display* base-frame-counter)) - ) - (set! (-> obj buzzer) buzz-count) - ) - (-> obj buzzer) - ) - (((pickup-type eco-red) (pickup-type eco-blue) (pickup-type eco-yellow)) - ;; the green vent jumps here. - (label cfg-80) - - ;; if the amount is zero, we just want to know how much eco there is. - (if (= amount 0.0) - (return (if (= (-> obj eco-type) kind) - (-> obj eco-level) - 0.0 ;; we don't have this kind of eco. - ) - ) - ) - - ;; new type of eco. Reset and use the new type. - (when (!= (-> obj eco-type) kind) - ;; as far as I can tell, the eco-level isn't really used other than just 1 or 0. - (set! (-> obj eco-level) 0.0) - (set! (-> obj eco-timeout) 0) - 0 - ) - (set! (-> obj eco-type) kind) - - - (let ((eco-lev (-> obj eco-level))) - (set! (-> obj eco-level) 1.0) ;; just set to 1. - - ;; this check now doesn't make much sense... - (when (and (= eco-lev 0.0) (< 0.0 (-> obj eco-level))) - ;; didn't have eco and now we do, remember when - (set! (-> obj eco-pickup-time) (-> *display* game-frame-counter)) - - ;; send a reset-collide message. Not sure why we do this. - (send-event (-> obj process) 'reset-collide) - ) - - ;; this logic prevents eco from respawning before you are out. - ;; the time until respawn is min(full_eco_time, old_time + single_timeout) - (set! (-> obj eco-timeout) - (the-as seconds - (min (the-as int (+ (-> obj eco-timeout) (* (the-as int (-> *FACT-bank* eco-single-timeout)) (the int amount)))) - (the-as int (+ (-> *FACT-bank* eco-full-timeout) (- (-> *display* game-frame-counter) (-> obj eco-pickup-time)))) - ) - ) - ) - - ;; if you max out the eco, this should trigger - (if (>= (the-as int (- (-> obj eco-timeout) (the-as uint (- (-> *display* game-frame-counter) (-> obj eco-pickup-time))))) - (the-as int (-> *FACT-bank* eco-full-timeout)) - ) - (set! (-> obj eco-level) 2.0) - ) - - - ;; sound and controller vibration. - (when (not (and (= (handle->process source-handle) (handle->process (-> obj eco-source))) - (< (- (-> *display* base-frame-counter) (-> obj eco-source-time)) (seconds 0.5)) - ) - ) - (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 127 (seconds 0.2)) - (cpad-set-buzz! (-> *cpad-list* cpads 0) 0 17 (seconds 0.2)) - (case kind - (((pickup-type eco-blue)) - (sound-play-by-name (static-sound-name "get-blue-eco") (new-sound-id) 1024 0 0 1 #t) - ) - (((pickup-type eco-green)) - (sound-play-by-name (static-sound-name "get-green-eco") (new-sound-id) 1024 0 0 1 #t) - ) - (((pickup-type eco-yellow)) - (sound-play-by-name (static-sound-name "get-yellow-eco") (new-sound-id) 1024 0 0 1 #t) - ) - (((pickup-type eco-red)) - (sound-play-by-name (static-sound-name "get-red-eco") (new-sound-id) 1024 0 0 1 #t) - ) - ) - ) - - (set! (-> obj eco-source) source-handle) - (set! (-> obj eco-source-time) (-> *display* base-frame-counter)) - - ;; special case for blue eco magnet effect - (when (= kind (pickup-type eco-blue)) - (when (= eco-lev 0.0) - (let ((s5-1 (-> obj process))) - (let* ((s3-5 (get-process *default-dead-pool* touch-tracker #x4000)) - (s4-3 - (when s3-5 - (let ((t9-28 (method-of-type touch-tracker activate))) - (t9-28 (the-as touch-tracker s3-5) s5-1 'touch-tracker (the-as pointer #x70004000)) - ) - (run-now-in-process s3-5 touch-tracker-init (-> s5-1 root trans) (-> *FACT-bank* suck-bounce-dist) 300) - (-> s3-5 ppointer) - ) - ) - ) - (send-event (ppointer->process s4-3) 'target s5-1) - (send-event (ppointer->process s4-3) 'event 'eco-blue) - (send-event (ppointer->process s4-3) 'exit (lambda () (send-event *target* 'query 'powerup 3))) - (send-event - (ppointer->process s4-3) - 'eval - (lambda :behavior process-drawable - () - (set! (-> (the-as collide-shape (-> self root)) root-prim collide-with) - (collide-kind cak-1 cak-2 cak-3 blue-eco-suck) - ) - (none) - ) - ) - ) - (let ((s4-4 (get-process *4k-dead-pool* process #x4000))) - (when s4-4 - (let ((t9-35 (method-of-type process activate))) - (t9-35 s4-4 s5-1 'process (the-as pointer #x70004000)) - ) - (run-next-time-in-process - s4-4 - (lambda ((arg0 process-drawable)) - (let ((s5-0 (-> *display* base-frame-counter))) - (until (>= (- (-> *display* base-frame-counter) s5-0) (seconds 0.6)) - (send-event arg0 'effect 'eco-blue) - (suspend) - ) - ) - (none) - ) - s5-1 - ) - (-> s4-4 ppointer) - ) - ) - ) - ) - ) - ) - (-> obj eco-level) - ) - (else - ((method-of-type fact-info pickup-collectable!) obj kind amount source-handle) + + ;; remember the source. + (when (handle->process source-handle) + (set! (-> obj eco-source) source-handle) + (set! (-> obj eco-source-time) (-> *display* base-frame-counter)) ) ) + + ;; if we are at max health (3), and collect additional an additional big green eco, + ;; then max out the little green ecos. + (if (= (-> obj health) (-> obj health-max)) + (pickup-collectable! + obj + (pickup-type eco-pill) + (-> *FACT-bank* eco-pill-max-default) + (process->handle (-> obj process)) + ) + ) + + ;; remember when + (set! (-> obj health-pickup-time) (-> *display* base-frame-counter)) + ;; increase the health! + (seek! (-> obj health) (-> obj health-max) amount) + ) + (else + ;; negative health. Subtract. + (seek! (-> obj health) 0.0 (- amount)) + + ;; not sure why we do this. But this will set the eco pill collection time. + (if (>= amount -10.0) + (pickup-collectable! obj (pickup-type eco-pill) 0.0 source-handle) + ) + + ;; subtract lives. + (if (= (-> obj health) 0.0) + (adjust (-> (the-as target (-> obj process)) game) 'life (- (-> *GAME-bank* life-single-inc)) source-handle) + ) + ) + ) + + ;; some sort of hack for eco vents. + (b! + (and (logtest? (-> (the-as collide-shape (-> obj process root)) root-prim prim-core action) (collide-action ca-9)) + (type-type? (-> (handle->process source-handle) type) vent) + ) + cfg-80 + :delay (nop!) + ) + (-> obj health) + ) + + (((pickup-type eco-pill)) + ;; collect small green eco + (when (>= amount 0.0) + ;; update small eco count + (set! (-> obj eco-pill-pickup-time) (-> *display* base-frame-counter)) + (seek! (-> obj eco-pill) (-> obj eco-pill-max) amount) + + ;; increment big health if needed + (when (and (>= (-> obj eco-pill) (-> *FACT-bank* eco-pill-max-default)) (< (-> obj health) (-> obj health-max))) + ;; decrease eco pills + (set! (-> obj eco-pill) (- (-> obj eco-pill) (-> *FACT-bank* eco-pill-max-default))) + ;; get a big health. + (pickup-collectable! + obj + (pickup-type eco-green) + (-> *FACT-bank* health-small-inc) + (process->handle (-> obj process)) + ) + ) + ) + (-> obj eco-pill) + ) + + (((pickup-type money)) + ;; get money. + (when (< 0.0 amount) + ;; play sound. + (if (>= (- (-> *display* base-frame-counter) (-> obj money-pickup-time)) (seconds 0.05)) + (sound-play-by-name (static-sound-name "money-pickup") (new-sound-id) 1024 0 0 1 #t) + ) + (set! (-> obj money-pickup-time) (-> *display* base-frame-counter)) + ) + (adjust (-> (the-as target (-> obj process)) game) 'money amount source-handle) + ) + (((pickup-type fuel-cell)) + ;; the amount is actually the index of the task. + (let ((s4-2 (the int amount))) + (if (not (or (task-complete? (-> (the-as target (-> obj process)) game) (the-as game-task s4-2)) + (>= (the-as uint 1) (the-as uint s4-2)) + ) + ) + (set! (-> obj fuel-cell-pickup-time) (-> *display* base-frame-counter)) + ) + ) + (adjust (-> (the-as target (-> obj process)) game) 'fuel-cell amount source-handle) + ) + (((pickup-type buzzer)) + ;; buzzer + (let ((buzz-count (adjust (-> (the-as target (-> obj process)) game) 'buzzer amount source-handle))) + (if (!= buzz-count (-> obj buzzer)) + (set! (-> obj buzzer-pickup-time) (-> *display* base-frame-counter)) + ) + (set! (-> obj buzzer) buzz-count) + ) + (-> obj buzzer) + ) + (((pickup-type eco-red) (pickup-type eco-blue) (pickup-type eco-yellow)) + ;; the green vent jumps here. + (label cfg-80) + + ;; if the amount is zero, we just want to know how much eco there is. + (if (= amount 0.0) + (return (if (= (-> obj eco-type) kind) + (-> obj eco-level) + 0.0 ;; we don't have this kind of eco. + ) + ) + ) + + ;; new type of eco. Reset and use the new type. + (when (!= (-> obj eco-type) kind) + ;; as far as I can tell, the eco-level isn't really used other than just 1 or 0. + (set! (-> obj eco-level) 0.0) + (set! (-> obj eco-timeout) 0) + ) + (set! (-> obj eco-type) kind) + + + (let ((eco-lev (-> obj eco-level))) + (set! (-> obj eco-level) 1.0) ;; just set to 1. + + ;; this check now doesn't make much sense... + (when (and (= eco-lev 0.0) (< 0.0 (-> obj eco-level))) + ;; didn't have eco and now we do, remember when + (set! (-> obj eco-pickup-time) (-> *display* game-frame-counter)) + + ;; send a reset-collide message. Not sure why we do this. + (send-event (-> obj process) 'reset-collide) + ) + + ;; this logic prevents eco from respawning before you are out. + ;; the time until respawn is min(full_eco_time, old_time + single_timeout) + (set! (-> obj eco-timeout) + (the-as seconds + (min (the-as int (+ (-> obj eco-timeout) (* (the-as int (-> *FACT-bank* eco-single-timeout)) (the int amount)))) + (the-as int (+ (-> *FACT-bank* eco-full-timeout) (- (-> *display* game-frame-counter) (-> obj eco-pickup-time)))) + ) + ) + ) + + ;; if you max out the eco, this should trigger + (if (>= (the-as int (- (-> obj eco-timeout) (the-as uint (- (-> *display* game-frame-counter) (-> obj eco-pickup-time))))) + (the-as int (-> *FACT-bank* eco-full-timeout)) + ) + (set! (-> obj eco-level) 2.0) + ) + + + ;; sound and controller vibration. + (when (not (and (= (handle->process source-handle) (handle->process (-> obj eco-source))) + (< (- (-> *display* base-frame-counter) (-> obj eco-source-time)) (seconds 0.5)) + ) + ) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 1 127 (seconds 0.2)) + (cpad-set-buzz! (-> *cpad-list* cpads 0) 0 17 (seconds 0.2)) + (case kind + (((pickup-type eco-blue)) + (sound-play-by-name (static-sound-name "get-blue-eco") (new-sound-id) 1024 0 0 1 #t) + ) + (((pickup-type eco-green)) + (sound-play-by-name (static-sound-name "get-green-eco") (new-sound-id) 1024 0 0 1 #t) + ) + (((pickup-type eco-yellow)) + (sound-play-by-name (static-sound-name "get-yellow-eco") (new-sound-id) 1024 0 0 1 #t) + ) + (((pickup-type eco-red)) + (sound-play-by-name (static-sound-name "get-red-eco") (new-sound-id) 1024 0 0 1 #t) + ) + ) + ) + + (set! (-> obj eco-source) source-handle) + (set! (-> obj eco-source-time) (-> *display* base-frame-counter)) + + ;; special case for blue eco magnet effect + (when (= kind (pickup-type eco-blue)) + (when (= eco-lev 0.0) + (let ((s5-1 (-> obj process))) + (let ((s4-3 + (process-spawn + touch-tracker + :init touch-tracker-init + (-> s5-1 root trans) + (-> *FACT-bank* suck-bounce-dist) + (seconds 1) + :to s5-1 + ) + ) + ) + (send-event (ppointer->process s4-3) 'target s5-1) + (send-event (ppointer->process s4-3) 'event 'eco-blue) + (send-event (ppointer->process s4-3) 'exit (lambda () (send-event *target* 'query 'powerup (pickup-type eco-blue)))) + (send-event + (ppointer->process s4-3) + 'eval + (lambda :behavior process-drawable + () + (set! (-> (the-as collide-shape (-> self root)) root-prim collide-with) + (collide-kind cak-1 cak-2 cak-3 blue-eco-suck) + ) + (none) + ) + ) + ) + (process-spawn-function + process + (lambda ((arg0 process-drawable)) + (let ((s5-0 (-> *display* base-frame-counter))) + (until (>= (- (-> *display* base-frame-counter) s5-0) (seconds 0.6)) + (send-event arg0 'effect 'eco-blue) + (suspend) + ) + ) + (none) + ) + s5-1 + :from *4k-dead-pool* + :to s5-1 + ) + ) + ) + ) + ) + (-> obj eco-level) + ) + (else + ((method-of-type fact-info pickup-collectable!) obj kind amount source-handle) + ) ) ) (defmethod lookup-entity-perm-by-aid game-info ((obj game-info) (aid actor-id)) (let ((v1-0 (-> obj perm-list))) - (countdown (a0-1 (-> v1-0 length)) - (if (= aid (-> v1-0 data a0-1 aid)) - (return (-> v1-0 data a0-1)) - ) + (countdown (a0-1 (-> v1-0 length)) + (if (= aid (-> v1-0 data a0-1 aid)) + (return (-> v1-0 data a0-1)) + ) + ) ) - ) (the-as entity-perm #f) ) @@ -872,13 +792,13 @@ (let ((info-entity-perm (lookup-entity-perm-by-aid obj (-> lev-entity-perm aid)))) (cond (info-entity-perm - ;; it exists, set it to the value from the level - (set! (-> info-entity-perm quad) (-> lev-entity-perm quad)) - ) + ;; it exists, set it to the value from the level + (set! (-> info-entity-perm quad) (-> lev-entity-perm quad)) + ) ((< (-> perms length) (-> perms allocated-length)) ;; nope, doesn't exist, but we have room for another, so add it to the back (set! (-> perms data (-> perms length) quad) (-> lev-entity-perm quad)) - (set! (-> perms length) (+ (-> perms length) 1)) + (+! (-> perms length) 1) ) ) ) @@ -901,17 +821,11 @@ ;; found the level entity in game-info, copy (set! (-> lev-entity-perm quad) (-> info-entity-perm quad)) ;; and also do this thing, not sure exactly what, but updates the status bits - (update-perm! lev-entity-perm 'try - (entity-perm-status - bit-0 - bit-1 - dead - bit-3 - user-set-from-cstage - complete - bit-9 + (update-perm! + lev-entity-perm + 'try + (entity-perm-status bit-0 bit-1 dead bit-3 user-set-from-cstage complete bit-9) ) - ) ) ) ) @@ -928,27 +842,24 @@ (defmethod debug-draw! continue-point ((obj continue-point)) "Draw a continue point." - (add-debug-x #t - (bucket-id debug-no-zbuf) - (-> obj trans) - (new 'static 'rgba :r #xff :a #x80) - ) - (add-debug-text-3d #t - (bucket-id debug-no-zbuf) - (-> obj name) - (-> obj trans) - (font-color white) - (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) - ) + (add-debug-x #t (bucket-id debug-no-zbuf) (-> obj trans) (new 'static 'rgba :r #xff :a #x80)) + (add-debug-text-3d + #t + (bucket-id debug-no-zbuf) + (-> obj name) + (-> obj trans) + (font-color white) + (new 'static 'vector2h :y 8) + ) (let ((a3-2 (vector-z-quaternion! (new-stack-vector0) (-> obj quat)))) (add-debug-vector - #t - (bucket-id debug-no-zbuf) - (-> obj trans) - a3-2 - 8192.0 - (new 'static 'rgba :r #xff :g #x80 :a #x80) - ) + #t + (bucket-id debug-no-zbuf) + (-> obj trans) + a3-2 + (meters 2.0) + (new 'static 'rgba :r #xff :g #x80 :a #x80) + ) ) 0 (none) @@ -957,46 +868,41 @@ (defun-debug trsq->continue-point ((arg0 trsq)) "Print out a continue point." (let ((a2-0 (level-get-target-inside *level*))) - (format #t "~%(static-continue-point ~A ()~%" - (symbol->string (-> a2-0 name)) - ) + (format #t "~%(static-continue-point ~A ()~%" (symbol->string (-> a2-0 name))) ) - (format #t " (target ~m ~m ~m " - (-> arg0 trans x) - (-> arg0 trans y) - (-> arg0 trans z) - ) - (format #t "~f ~f ~f ~f)~%" - (-> arg0 quat x) - (-> arg0 quat y) - (-> arg0 quat z) - (-> arg0 quat w) - ) + (format #t " (target ~m ~m ~m " (-> arg0 trans x) (-> arg0 trans y) (-> arg0 trans z)) + (format #t "~f ~f ~f ~f)~%" (-> arg0 quat x) (-> arg0 quat y) (-> arg0 quat z) (-> arg0 quat w)) (let ((gp-1 *math-camera*)) - (format #t " (camera ~m ~m ~m ~f ~f ~f " - (-> gp-1 trans x) - (-> gp-1 trans y) - (-> gp-1 trans z) - (-> gp-1 inv-camera-rot vector 0 x) - (-> gp-1 inv-camera-rot vector 0 y) - (-> gp-1 inv-camera-rot vector 0 z) - ) - (format #t "~f ~f ~f ~f ~f ~f)~%" - (-> gp-1 inv-camera-rot vector 1 x) - (-> gp-1 inv-camera-rot vector 1 y) - (-> gp-1 inv-camera-rot vector 1 z) - (-> gp-1 inv-camera-rot vector 2 x) - (-> gp-1 inv-camera-rot vector 2 y) - (-> gp-1 inv-camera-rot vector 2 z) - ) + (format + #t + " (camera ~m ~m ~m ~f ~f ~f " + (-> gp-1 trans x) + (-> gp-1 trans y) + (-> gp-1 trans z) + (-> gp-1 inv-camera-rot vector 0 x) + (-> gp-1 inv-camera-rot vector 0 y) + (-> gp-1 inv-camera-rot vector 0 z) + ) + (format + #t + "~f ~f ~f ~f ~f ~f)~%" + (-> gp-1 inv-camera-rot vector 1 x) + (-> gp-1 inv-camera-rot vector 1 y) + (-> gp-1 inv-camera-rot vector 1 z) + (-> gp-1 inv-camera-rot vector 2 x) + (-> gp-1 inv-camera-rot vector 2 y) + (-> gp-1 inv-camera-rot vector 2 z) + ) + ) + (format + #t + " (load '~A '~A '~A '~A '~A)~%" + (-> *load-state* vis-nick) + (-> *load-state* want 0 name) + (-> *load-state* want 0 display?) + (-> *load-state* want 1 name) + (-> *load-state* want 1 display?) ) - (format #t " (load '~A '~A '~A '~A '~A)~%" - (-> *load-state* vis-nick) - (-> *load-state* want 0 name) - (-> *load-state* want 0 display?) - (-> *load-state* want 1 name) - (-> *load-state* want 1 display?) - ) (format #t " )~%") 0 (none) @@ -1043,10 +949,7 @@ (dotimes (a0-24 (-> v1-15 length)) (set! (-> v1-15 data a0-24 task) (the-as game-task a0-24)) ) - (set! - (-> v1-15 data 1 status) - (logior (-> v1-15 data 1 status) (entity-perm-status real-complete)) - ) + (logior! (-> v1-15 data 1 status) (entity-perm-status real-complete)) ) ) @@ -1080,17 +983,13 @@ (defmethod get-death-count game-info ((obj game-info) (arg0 symbol)) (let ((v1-13 - (if (and arg0 - *target* - (>= (-> *level-task-data-remap* length) (-> *target* current-level info index)) - ) - (the-as int - (-> obj deaths-per-level - (-> *level-task-data-remap* (+ (-> *target* current-level info index) -1)) - ) - ) - (-> obj fuel-cell-deaths) - ) + (if (and arg0 *target* (>= (-> *level-task-data-remap* length) (-> *target* current-level info index))) + (the-as + int + (-> obj deaths-per-level (-> *level-task-data-remap* (+ (-> *target* current-level info index) -1))) + ) + (-> obj fuel-cell-deaths) + ) ) ) 0 @@ -1101,3 +1000,7 @@ (defmethod get-health-percent-lost game-info ((obj game-info) (arg0 symbol)) (* 0.25 (the float (get-death-count obj #f))) ) + + + + diff --git a/goal_src/engine/sound/gsound.gc b/goal_src/engine/sound/gsound.gc index d090d1ca0f..b30771c4a9 100644 --- a/goal_src/engine/sound/gsound.gc +++ b/goal_src/engine/sound/gsound.gc @@ -337,20 +337,16 @@ `(with-pp (let ((proc (the process-drawable pp))) - ;(format 0 "get proc~%") (when (= ,sound-trans #t) - ;(format 0 "trans #t~%") (if (and proc (type-type? (-> proc type) process-drawable) (nonzero? (-> proc root))) (set! ,sound-trans (-> proc root trans)) (set! ,sound-trans (the vector #f)) ) - ;(format 0 "trans is ~A~%" ,sound-trans) ) ) - ;(format 0 "convert~%" ,sound-trans) (sound-trans-convert (-> ,cmd parms trans) ,sound-trans) ) ) @@ -359,37 +355,24 @@ "Play a sound called name with the specified params" (local-vars (sv-16 int)) - (with-pp - (set! sv-16 group) - (let ((sound-trans (the-as structure trans))) + (set! sv-16 group) + (let ((sound-trans (the-as vector trans))) (when *sound-player-enable* - (let ((cmd (the-as sound-rpc-play (get-sound-buffer-entry)))) - (set! (-> cmd command) (sound-command play)) - (set! (-> cmd id) id) - (set! (-> cmd name) name) - (set! (-> cmd parms mask) (sound-mask)) - (set! (-> cmd parms group) (the-as uint sv-16)) - (set! (-> cmd parms volume) vol) - (set! (-> cmd parms pitch-mod) pitch) - (set! (-> cmd parms bend) bend) - (let ((proc (the-as process-drawable pp))) - (when (= (the-as symbol sound-trans) #t) - (if - (and - proc - (type-type? (-> proc type) process-drawable) - (nonzero? (-> proc root)) - ) - (set! sound-trans (-> proc root trans)) - (set! sound-trans #f) - ) + (let ((cmd (the-as sound-rpc-play (get-sound-buffer-entry)))) + + (set! (-> cmd command) (sound-command play)) + (set! (-> cmd id) id) + (set! (-> cmd name) name) + (set! (-> cmd parms mask) (sound-mask)) + (set! (-> cmd parms group) (the-as uint sv-16)) + (set! (-> cmd parms volume) vol) + (set! (-> cmd parms pitch-mod) pitch) + (set! (-> cmd parms bend) bend) + + (sound-trans-from-process cmd sound-trans) ) - ) - (sound-trans-convert (-> cmd parms trans) (the-as vector sound-trans)) ) - ) ) - ) id ) diff --git a/goal_src/pc/hud-classes-pc.gc b/goal_src/pc/hud-classes-pc.gc index b7f6009196..7cd4cc898e 100644 --- a/goal_src/pc/hud-classes-pc.gc +++ b/goal_src/pc/hud-classes-pc.gc @@ -82,7 +82,7 @@ &key scale-y &key (entity #f) ) - `(when (< (-> ,obj nb-of-icons) 6) + `(when (< (-> ,obj nb-of-icons) ,max) (let ((icon-idx (-> ,obj nb-of-icons))) (set! (-> ,obj icons icon-idx) (new 'static 'hud-icon)) (let ((new-manipy (manipy-spawn (new 'static 'vector :w 1.0) ,entity ,skel #f diff --git a/goal_src/pc/pckernel.gc b/goal_src/pc/pckernel.gc index 017e2a0be1..1ee44909ee 100644 --- a/goal_src/pc/pckernel.gc +++ b/goal_src/pc/pckernel.gc @@ -90,7 +90,7 @@ (defmethod commit-to-file pc-settings ((obj pc-settings)) "commits the current settings to the file" ;; auto load settings if available - + (format (clear *pc-temp-string-1*) "~S/pc-settings.gc" *pc-settings-folder*) (pc-mkdir-file-path *pc-temp-string-1*) (write-to-file obj *pc-temp-string-1*) @@ -320,44 +320,58 @@ (when *target* - ;; TODO green eco hack here as well + (with-pp (protect ((-> *target* fact-info-target eco-source) *sound-player-enable*) + ;; act as if this isnt a new source of eco to prevent spamming sounds. then restore the old source! + (when (< 0 (-> *target* fact-info-target eco-level)) + (set! (-> *target* fact-info-target eco-source) (process->handle pp)) + (false! *sound-player-enable*) + ) + + ;; blue eco! (when (and (pc-cheats? obj eco-blue) (or (= (-> *target* fact-info-target eco-type) (pickup-type eco-blue)) (<= (-> *target* fact-info-target eco-level) 0.0))) - (send-event *target* 'get-pickup (pickup-type eco-blue) (-> *FACT-bank* eco-full-inc))) + (protect ((-> *target* event-hook)) + (set! (-> *target* event-hook) target-generic-event-handler) + (send-event *target* 'get-pickup (pickup-type eco-blue) (-> *FACT-bank* eco-full-inc)) + ) + (send-event *target* 'boost (-> *FACT-bank* eco-single-inc))) + ;; yellow eco! (when (and (pc-cheats? obj eco-yellow) (or (= (-> *target* fact-info-target eco-type) (pickup-type eco-yellow)) (<= (-> *target* fact-info-target eco-level) 0.0))) (send-event *target* 'get-pickup (pickup-type eco-yellow) (-> *FACT-bank* eco-full-inc))) + ;; red eco! (when (and (pc-cheats? obj eco-red) (or (= (-> *target* fact-info-target eco-type) (pickup-type eco-red)) (<= (-> *target* fact-info-target eco-level) 0.0))) (send-event *target* 'get-pickup (pickup-type eco-red) (-> *FACT-bank* eco-full-inc))) + ;; green eco! (when (and (pc-cheats? obj eco-green) (or (= (-> *target* fact-info-target eco-type) (pickup-type eco-green)) (<= (-> *target* fact-info-target eco-level) 0.0))) - (with-pp (define-extern vent type) - (protect ((-> (the basic pp) type) (-> *target* control root-prim prim-core action)) - (set! (-> (the basic pp) type) vent) - (logior! (-> *target* control root-prim prim-core action) #x200) + (protect ((-> pp type) (-> *target* control root-prim prim-core action)) + (set! (-> pp type) vent) + (logior! (-> *target* control root-prim prim-core action) (collide-action ca-9)) (send-event *target* 'get-pickup (pickup-type eco-green) (-> *FACT-bank* eco-full-inc))) - )) + ) + )) (when (pc-cheats? obj invinc) - (logior! (-> *target* state-flags) 16) + (logior! (-> *target* state-flags) (state-flags sf04)) ) ) - + (if (pc-cheats? obj tunes) (set! (-> obj flava-hack) -1) (set! (-> obj flava-hack) 0) ) - + (logior! (-> obj cheats-known) (-> obj cheats)) 0) @@ -365,7 +379,7 @@ (defmethod add-to-music-log pc-settings ((obj pc-settings) (music symbol) (flava int)) "add music and flava information to the music log. if music already exists, adds flava. if flava already exists, nothing happens." - + ;; go through our music log (dotimes (i PC_MUSIC_LOG_LENGTH) (cond @@ -383,15 +397,15 @@ ;; something else. maybe the wrong entry, in which case nothing to do. ) ) - + 0) (defmethod update-music-log pc-settings ((obj pc-settings)) "update music log settings." - + ;; add whatever is playing to the music log. (add-to-music-log obj (-> *setting-control* current music) (the int (-> *setting-control* current sound-flava))) - + ;; special cases. for example, npc's that despawn and you can't hear their music anymore. (if (task-closed? (game-task beach-ecorocks) (task-status need-introduction)) (add-to-music-log obj 'village1 1)) @@ -428,7 +442,7 @@ (add-to-music-log obj 'credits 1) (add-to-music-log obj 'credits 2) ) - + 0) @@ -472,12 +486,12 @@ (defun-debug print-music-log ((out object)) "prints the *pc-settings* music log." - + (dotimes (i PC_MUSIC_LOG_LENGTH) (if (-> *pc-settings* secrets music i name) (format out "music log ~D: ~A (f #x~x)~%" i (-> *pc-settings* secrets music i name) (-> *pc-settings* secrets music i flava-mask))) ) - + 0) @@ -883,7 +897,7 @@ (defmethod load-settings pc-settings ((obj pc-settings)) "load" - + (format (clear *pc-temp-string-1*) "~S/pc-settings.gc" *pc-settings-folder*) (if (pc-filepath-exists? *pc-temp-string-1*) (begin diff --git a/test/decompiler/reference/engine/game/game-info_REF.gc b/test/decompiler/reference/engine/game/game-info_REF.gc index cb8adb5d97..48e4220ef5 100644 --- a/test/decompiler/reference/engine/game/game-info_REF.gc +++ b/test/decompiler/reference/engine/game/game-info_REF.gc @@ -257,12 +257,12 @@ ) (let ((s2-0 (the-as (function cpu-thread function object object object object pointer) set-to-run)) (s1-0 (-> s3-1 main-thread)) - (s0-0 (lambda ((arg0 symbol) (arg1 symbol) (arg2 continue-point) (arg3 symbol)) + (s0-0 (lambda ((arg0 symbol) (arg1 symbol) (arg2 continue-point) (arg3 game-save)) (stop arg0) (reset-actors arg1) (set-continue! *game-info* arg2) (when arg3 - (load-game! *game-info* (the-as game-save arg3)) + (load-game! *game-info* arg3) (set! arg2 (get-or-create-continue! *game-info*)) ) (suspend)