fix: SAMs unable to target warheads due to close spawns - #4911
Conversation
…early for SAM targeting. Fix various visual glitches related to pre-spawned nukes. Combine all nuke specific properties into NukeState.
WalkthroughThe PR adds shared nuke wait-state data, stages MIRV warheads before separation, updates SAM timing and reloads, and hides waiting units from client rendering and telegraphs. ChangesMIRV nuke execution and rendering
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/client/render/frame/derive/NukeTelegraphs.ts (1)
50-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDefine the motion-plan input shape in renderer types.
The two exported functions repeat the inline
{ startTick: number }shape.GameViewpasses this map across the view and renderer boundary. Define a shared motion-plan timing interface insrc/client/render/types/and use it in both signatures and the producer type.As per coding guidelines, shared renderer pass-input shapes should be defined in
src/client/render/types/.Also applies to: 89-90
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/client/render/frame/derive/NukeTelegraphs.ts` around lines 50 - 51, Define a shared motion-plan timing interface in the renderer types and use it for the motionPlans parameter in both exported functions in NukeTelegraphs. Update the GameView producer’s map type to reference the same interface, preserving the existing startTick contract across the view-to-renderer boundary.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/client/render/frame/derive/NukeTelegraphs.ts`:
- Around line 50-59: Add the UnitState.waitTicks check to both telegraph
extractor predicates, alongside the existing targetTile, isActive, and
motionPlans checks. Suppress telegraphs whenever a warhead has positive
waitTicks, including when no delayed motion plan exists, while preserving
current behavior for non-waiting units.
In `@src/core/execution/MIRVExecution.ts`:
- Around line 189-190: Replace the fractional speed offset calculation in
MIRVExecution’s NukeExecution creation loop with integer threshold logic that
assigns one of five speed bands based on the warhead index and warhead count.
Ensure the resulting speed offset is integral before constructing each
NukeExecution, while preserving the existing band progression.
In `@tests/core/executions/SAMLauncherExecution.test.ts`:
- Around line 496-503: Update the wait-loop assertions around
attacker.units(UnitType.MIRVWarhead) so disappearance during the waiting period
fails instead of marking the test inconclusive. Track whether at least one
positive nukeState().waitTicks observation occurred with an empty
sam.missileTimerQueue(), assert that observation was made, and then verify the
SAM fires only after the wait period reaches zero.
---
Nitpick comments:
In `@src/client/render/frame/derive/NukeTelegraphs.ts`:
- Around line 50-51: Define a shared motion-plan timing interface in the
renderer types and use it for the motionPlans parameter in both exported
functions in NukeTelegraphs. Update the GameView producer’s map type to
reference the same interface, preserving the existing startTick contract across
the view-to-renderer boundary.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 10b2f1a1-8154-4f9b-a3ba-9be13a7ed145
📒 Files selected for processing (14)
src/client/render/frame/derive/NukeTelegraphs.tssrc/client/render/gl/passes/PointLightPass.tssrc/client/render/gl/passes/UnitPass.tssrc/client/render/types/Renderer.tssrc/client/view/GameView.tssrc/client/view/UnitView.tssrc/core/execution/MIRVExecution.tssrc/core/execution/NukeExecution.tssrc/core/execution/SAMLauncherExecution.tssrc/core/game/Game.tssrc/core/game/GameUpdates.tssrc/core/game/UnitImpl.tstests/core/executions/SAMLauncherExecution.test.tstests/nukes/HydrogenAndMirv.test.ts
|
Do not merge yet. Claude, gemini and Rabbit all missed an issue. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/nukes/HydrogenAndMirv.test.ts`:
- Around line 254-257: Remove the isOverlapping spy from the MIRV
target-generation test and configure the map and ownership state so
tryGenerateTarget passes the real 55-pixel minimumSpread check. Keep the test
focused on the resulting staged target behavior and assert the expected warhead
wait ticks without patching MirvExecution.prototype.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 365966fa-747d-40dd-a26f-b117dfa8f35f
📒 Files selected for processing (2)
src/core/execution/MIRVExecution.tstests/nukes/HydrogenAndMirv.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/core/execution/MIRVExecution.ts
|
This is now good to go |
Add approved & assigned issue number here:
Resolves #4909
Description:
generate warhead target locations over time. Spawn warheads 10 ticks early for SAM targeting. Fix various visual glitches related to pre-spawned nukes. Combine all nuke specific properties into NukeState. SAMs can reload multiple times during ticks if valid.
Please complete the following:
Before:
Please put your Discord username so you can be contacted if a bug or regression is found:
JB940