From 5b75cb74dff2b7434c54e4d6f2ef83cc1f48682e Mon Sep 17 00:00:00 2001 From: Matt Dallmeyer Date: Mon, 4 May 2026 07:09:10 -0400 Subject: [PATCH] [jak3] Prevent NaN propagation in spydroid attack state (#4237) Another patch to prevent NaN propagation. Still doesn't address the root cause of the NaNs, but should fix some mission behavior. In some cases, crimson-guards will [return NaN vectors for their `bullseye-joint`](https://github.com/open-goal/jak-project/blob/1dff57182004f058848b26f0f8bfbb111a96e480/goal_src/jak3/engine/ai/enemy.gc#L178-L183). I suspect the root cause of these NaNs may be related to the guards missing their torsos image In the [spydroid's `attack` state](https://github.com/open-goal/jak-project/blob/1dff57182004f058848b26f0f8bfbb111a96e480/goal_src/jak3/levels/common/enemy/spydroid.gc#L743-L772), this NaN value will end up propagating to the spydroid's position. This in turn causes issues like the infinite looping addressed in #4225. Or another issue in "Defend HQ From Attack" - every spydroid spawned by the task manager can end up with NaN positions. The spydroids will be nowhere to be seen, but the task-manager still considers them alive and won't spawn any other KG enemies. --- goal_src/jak3/levels/common/enemy/spydroid.gc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/goal_src/jak3/levels/common/enemy/spydroid.gc b/goal_src/jak3/levels/common/enemy/spydroid.gc index 2d335f3134..8e2de84834 100644 --- a/goal_src/jak3/levels/common/enemy/spydroid.gc +++ b/goal_src/jak3/levels/common/enemy/spydroid.gc @@ -745,6 +745,9 @@ (when a0-2 (let ((s5-0 (new 'stack-no-clear 'vector))) (vector-copy! s5-0 (get-trans a0-2 3)) + ;; og:preserve-this prevent NaN propagation - if bullseye-joint (3) returns NaNs, fall back to root trans (0) + (when (is-nan? (-> s5-0 x)) + (vector-copy! s5-0 (get-trans a0-2 0))) (vector-! gp-0 s5-0 (-> self root trans)) ) )