From e30ecb361ff467f56cddff059f800ff4734c8269 Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Mon, 15 May 2023 17:26:25 +0100 Subject: [PATCH] small jak 2 bug fixes (#2649) - elec gates now always render at max quality if you have PS2 lods disabled. the original render distances are so low that the one in caspad is impossible to see in normal gameplay. - `fort-entry-gate-11` and `com-airlock-outer-13` are specifically banned from the all actors hack because they are placed in a bad spot and Naughty Dog did not program the airlocks very well. - fixed NPC talk distance being bad for 1 frame. - fix `sew-scare-grunt` erroneously keeping its spool anim active if you killed the enemy. --- decompiler/config/jak2/all-types.gc | 4 ++-- goal_src/jak2/engine/entity/entity.gc | 5 ++++- goal_src/jak2/engine/level/level.gc | 3 --- .../process-drawable/process-taskable.gc | 4 +++- goal_src/jak2/levels/common/elec-gate.gc | 19 ++++++++++++------- goal_src/jak2/levels/sewer/sewer-obs2.gc | 3 +++ .../jak2/levels/common/elec-gate_REF.gc | 12 ++++++------ 7 files changed, 30 insertions(+), 20 deletions(-) diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 5ef40f4981..f16822b8a2 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -34853,8 +34853,8 @@ (part-off sparticle-launch-control :offset-assert 368) (part-spawner-left part-spawner :offset-assert 372) (part-spawner-right part-spawner :offset-assert 376) - (on-start basic :offset-assert 380) - (on-stop basic :offset-assert 384) + (on-start pair :offset-assert 380) + (on-stop pair :offset-assert 384) (dividing-wall elec-wall :inline :offset-assert 400) (plane elec-wall 2 :inline :offset-assert 432) (wall-y float :offset-assert 496) diff --git a/goal_src/jak2/engine/entity/entity.gc b/goal_src/jak2/engine/entity/entity.gc index 3ddeda1276..2e6441fb89 100644 --- a/goal_src/jak2/engine/entity/entity.gc +++ b/goal_src/jak2/engine/entity/entity.gc @@ -2231,7 +2231,10 @@ (dotimes (s1-1 s2-3) (set! sv-48 (-> s3-4 data s1-1)) (cond - ((and (#if PC_PORT (or (with-pc (-> *pc-settings* force-actors?)) (is-object-visible? s4-1 (-> sv-48 vis-id))) + ((and (#if PC_PORT (or (with-pc (and (-> *pc-settings* force-actors?) (not (let ((name (res-lump-struct (-> sv-48 entity) 'name string))) + (or (string= name "fort-entry-gate-11") + (string= name "com-airlock-outer-13")))))) + (is-object-visible? s4-1 (-> sv-48 vis-id))) (is-object-visible? s4-1 (-> sv-48 vis-id))) (not (logtest? (-> sv-48 perm status) (entity-perm-status bit-9 bit-10))) (not (logtest? (-> sv-48 kill-mask) sv-32)) diff --git a/goal_src/jak2/engine/level/level.gc b/goal_src/jak2/engine/level/level.gc index 3f7c6ac4b3..72a5789a7d 100644 --- a/goal_src/jak2/engine/level/level.gc +++ b/goal_src/jak2/engine/level/level.gc @@ -1761,9 +1761,6 @@ into 7 sections, which might explain the weird sizes in the center. (defmethod is-object-visible? level ((obj level) (arg0 int)) "Is drawable arg0 visible? Note that this will return #f if the visibility data is not loaded." - ;; note : pc port added option to show every actor regardless - (with-pc (if (-> *pc-settings* force-actors?) (return #t))) - ;; check the vis bits! (let* (;; lwu v1, 388(a0) (vis-data (-> obj vis-bits)) diff --git a/goal_src/jak2/engine/process-drawable/process-taskable.gc b/goal_src/jak2/engine/process-drawable/process-taskable.gc index a2062b86c2..7074745697 100644 --- a/goal_src/jak2/engine/process-drawable/process-taskable.gc +++ b/goal_src/jak2/engine/process-drawable/process-taskable.gc @@ -216,7 +216,9 @@ Seen take in - `true-func` which takes no args TODO - seems fishy ) ) ) - (< (vector-vector-distance (target-pos 0) s5-0) f30-0) + ;; PC PORT NOTE : added check so we don't use the wrong position for the distance check + (and (logtest? (-> self draw status) (draw-control-status lod-set)) + (< (vector-vector-distance (target-pos 0) s5-0) f30-0)) ) ) (< (- (-> self clock frame-counter) (-> self want-to-say)) (seconds 4)) diff --git a/goal_src/jak2/levels/common/elec-gate.gc b/goal_src/jak2/levels/common/elec-gate.gc index 86998db490..6465896e46 100644 --- a/goal_src/jak2/levels/common/elec-gate.gc +++ b/goal_src/jak2/levels/common/elec-gate.gc @@ -51,8 +51,8 @@ (part-off sparticle-launch-control :offset-assert 368) (part-spawner-left part-spawner :offset-assert 372) (part-spawner-right part-spawner :offset-assert 376) - (on-start basic :offset-assert 380) - (on-stop basic :offset-assert 384) + (on-start pair :offset-assert 380) + (on-stop pair :offset-assert 384) (dividing-wall elec-wall :inline :offset-assert 400) (plane elec-wall 2 :inline :offset-assert 432) (wall-y float :offset-assert 496) @@ -256,7 +256,7 @@ :enter (behavior () (process-entity-status! self (entity-perm-status subtask-complete) #f) (if (-> self on-start) - (script-eval (the-as pair (-> self on-start)) :vector (-> self root trans)) + (script-eval (-> self on-start) :vector (-> self root trans)) ) (dotimes (bolt-idx 5) (let* ((curr-bolt (-> self l-bolt bolt-idx bolt)) @@ -480,6 +480,9 @@ (set! (-> self lightning-quality) (lerp-scale 0.0 1.0 (vector-vector-distance focus-trans (-> self root trans)) 491520.0 163840.0) ) + ;; changed for PC port so lightning can always render from farther than 2 inches away... + (#when PC_PORT + (if (not (-> *pc-settings* ps2-lod-dist?)) (set! (-> self lightning-quality) 1.0))) ) ) ) @@ -635,7 +638,7 @@ (sound-play "elec-gate-off") (blocking-plane-destroy) (if (-> self on-stop) - (script-eval (the-as pair (-> self on-stop)) :vector (-> self root trans)) + (script-eval (-> self on-stop) :vector (-> self root trans)) ) (none) ) @@ -725,7 +728,9 @@ (defmethod set-elec-scale-if-close! elec-gate ((obj elec-gate) (arg0 float)) "If [[target]]'s position is within `80` [[meters]], set the scale to the value provided @see [[elec-gate::29]]" - (if (< (vector-vector-distance (-> obj root trans) (target-pos 0)) 327680.0) + ;; changed for PC port so we can render it at any distance + (if (#if PC_PORT (or (not (-> *pc-settings* ps2-lod-dist?)) (< (vector-vector-distance (-> obj root trans) (target-pos 0)) (meters 80))) + (< (vector-vector-distance (-> obj root trans) (target-pos 0)) (meters 80))) (set-elec-scale! obj arg0) ) 0 @@ -879,8 +884,8 @@ This commonly includes things such as: (set! (-> obj sound) (new 'process 'ambient-sound (static-sound-spec "electric-gate" :fo-max 70) (-> obj root trans)) ) - (set! (-> obj on-start) (res-lump-struct (-> obj entity) 'on-start basic)) - (set! (-> obj on-stop) (res-lump-struct (-> obj entity) 'on-stop basic)) + (set! (-> obj on-start) (res-lump-struct (-> obj entity) 'on-start pair)) + (set! (-> obj on-stop) (res-lump-struct (-> obj entity) 'on-stop pair)) (elec-gate-method-24 obj) (set-palette! obj) (set-state! obj) diff --git a/goal_src/jak2/levels/sewer/sewer-obs2.gc b/goal_src/jak2/levels/sewer/sewer-obs2.gc index 7ff2a8d094..0cfa39af91 100644 --- a/goal_src/jak2/levels/sewer/sewer-obs2.gc +++ b/goal_src/jak2/levels/sewer/sewer-obs2.gc @@ -1667,6 +1667,9 @@ This commonly includes things such as: (logclear! (-> (the-as sew-grill actor-proc) draw status) (draw-control-status no-draw)) ) ) + ;; pc port note : fix bug where the spool anim never gets aborted + (#when PC_PORT + (ja-abort-spooled-anim (-> self anim) (the-as art-joint-anim #f) -1)) (none) ) :code (behavior () diff --git a/test/decompiler/reference/jak2/levels/common/elec-gate_REF.gc b/test/decompiler/reference/jak2/levels/common/elec-gate_REF.gc index 0fb8b90ccc..90c5b48b7d 100644 --- a/test/decompiler/reference/jak2/levels/common/elec-gate_REF.gc +++ b/test/decompiler/reference/jak2/levels/common/elec-gate_REF.gc @@ -90,8 +90,8 @@ (part-off sparticle-launch-control :offset-assert 368) (part-spawner-left part-spawner :offset-assert 372) (part-spawner-right part-spawner :offset-assert 376) - (on-start basic :offset-assert 380) - (on-stop basic :offset-assert 384) + (on-start pair :offset-assert 380) + (on-stop pair :offset-assert 384) (dividing-wall elec-wall :inline :offset-assert 400) (plane elec-wall 2 :inline :offset-assert 432) (wall-y float :offset-assert 496) @@ -328,7 +328,7 @@ :enter (behavior () (process-entity-status! self (entity-perm-status subtask-complete) #f) (if (-> self on-start) - (script-eval (the-as pair (-> self on-start)) :vector (-> self root trans)) + (script-eval (-> self on-start) :vector (-> self root trans)) ) (dotimes (bolt-idx 5) (let* ((curr-bolt (-> self l-bolt bolt-idx bolt)) @@ -708,7 +708,7 @@ (sound-play "elec-gate-off") (blocking-plane-destroy) (if (-> self on-stop) - (script-eval (the-as pair (-> self on-stop)) :vector (-> self root trans)) + (script-eval (-> self on-stop) :vector (-> self root trans)) ) (none) ) @@ -967,8 +967,8 @@ This commonly includes things such as: (set! (-> obj sound) (new 'process 'ambient-sound (static-sound-spec "electric-gate" :fo-max 70) (-> obj root trans)) ) - (set! (-> obj on-start) (res-lump-struct (-> obj entity) 'on-start basic)) - (set! (-> obj on-stop) (res-lump-struct (-> obj entity) 'on-stop basic)) + (set! (-> obj on-start) (res-lump-struct (-> obj entity) 'on-start pair)) + (set! (-> obj on-stop) (res-lump-struct (-> obj entity) 'on-stop pair)) (elec-gate-method-24 obj) (set-palette! obj) (set-state! obj)