Skip to content

fix: SAMs unable to target warheads due to close spawns - #4911

Open
JB940 wants to merge 4 commits into
mainfrom
fix/warhead-early-spawn-nuke-internals
Open

fix: SAMs unable to target warheads due to close spawns#4911
JB940 wants to merge 4 commits into
mainfrom
fix/warhead-early-spawn-nuke-internals

Conversation

@JB940

@JB940 JB940 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Before opening a PR: discuss new features on Discord first, and file bugs or small improvements as issues. You must be assigned to an approved issue — unsolicited PRs will be auto-closed.

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:

  • I have added relevant tests to the test directory
  • I have added gifs of gameplay differences
    Before:
Image After: Image

Please put your Discord username so you can be contacted if a bug or regression is found:

JB940

…early for SAM targeting. Fix various visual glitches related to pre-spawned nukes. Combine all nuke specific properties into NukeState.
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The 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.

Changes

MIRV nuke execution and rendering

Layer / File(s) Summary
Nuke state contract and propagation
src/core/game/Game.ts, src/core/game/GameUpdates.ts, src/core/game/UnitImpl.ts, src/client/view/UnitView.ts, src/client/render/types/Renderer.ts
Nuke trajectory, SAM-targeting, and waitTicks data now use shared state across game updates, unit views, and renderer state.
Precomputed MIRV flight and warhead staging
src/core/execution/MIRVExecution.ts, tests/nukes/HydrogenAndMirv.test.ts
MIRV paths and destinations are prepared before separation. Warheads spawn with delayed waits and adjusted launch data.
Wait-aware nuke execution and SAM reloads
src/core/execution/NukeExecution.ts, src/core/execution/SAMLauncherExecution.ts, tests/core/executions/SAMLauncherExecution.test.ts
Nuke wait state stays synchronized. SAM interception timing includes wait delays, and all expired missile timers reload in one tick.
Wait-aware telegraph and unit rendering
src/client/render/frame/derive/NukeTelegraphs.ts, src/client/view/GameView.ts, src/client/render/gl/UnitPass.ts, src/client/render/gl/PointLightPass.ts, tests/*
Telegraphs use motion start ticks. Waiting units are excluded from unit and light rendering. Test fixtures now provide waitTicks.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: evanpelle

Poem

MIRV paths cross the sky,
Warheads wait, then fly.
SAMs track each delayed beat,
Reloads clear the missile fleet.
Telegraphs start on time.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary fix: enabling SAMs to target MIRV warheads.
Description check ✅ Passed The description directly covers warhead pre-spawning, SAM targeting, visual fixes, state consolidation, and reload behavior.
Linked Issues check ✅ Passed The changes address issue #4909 by improving MIRV timing, SAM interception windows, reload processing, and waiting-warhead visibility.
Out of Scope Changes check ✅ Passed The changes remain within issue #4909 scope, including MIRV timing, SAM behavior, nuke state handling, and related rendering fixes.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/client/render/frame/derive/NukeTelegraphs.ts (1)

50-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Define the motion-plan input shape in renderer types.

The two exported functions repeat the inline { startTick: number } shape. GameView passes this map across the view and renderer boundary. Define a shared motion-plan timing interface in src/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

📥 Commits

Reviewing files that changed from the base of the PR and between 332e541 and 3e8d52d.

📒 Files selected for processing (14)
  • src/client/render/frame/derive/NukeTelegraphs.ts
  • src/client/render/gl/passes/PointLightPass.ts
  • src/client/render/gl/passes/UnitPass.ts
  • src/client/render/types/Renderer.ts
  • src/client/view/GameView.ts
  • src/client/view/UnitView.ts
  • src/core/execution/MIRVExecution.ts
  • src/core/execution/NukeExecution.ts
  • src/core/execution/SAMLauncherExecution.ts
  • src/core/game/Game.ts
  • src/core/game/GameUpdates.ts
  • src/core/game/UnitImpl.ts
  • tests/core/executions/SAMLauncherExecution.test.ts
  • tests/nukes/HydrogenAndMirv.test.ts

Comment thread src/client/render/frame/derive/NukeTelegraphs.ts
Comment thread src/core/execution/MIRVExecution.ts Outdated
Comment thread tests/core/executions/SAMLauncherExecution.test.ts
@github-project-automation github-project-automation Bot moved this from Triage to Development in OpenFront Release Management Aug 8, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 8, 2026
@JB940

JB940 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Do not merge yet. Claude, gemini and Rabbit all missed an issue.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 149a660 and 1c12811.

📒 Files selected for processing (2)
  • src/core/execution/MIRVExecution.ts
  • tests/nukes/HydrogenAndMirv.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/execution/MIRVExecution.ts

Comment thread tests/nukes/HydrogenAndMirv.test.ts
@JB940

JB940 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

This is now good to go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Development

Development

Successfully merging this pull request may close these issues.

SAMs are unable to intercept MIRV warheads in various cases.

1 participant