Skip to content

Test/sam refire#3350

Draft
Caleb-Cohen wants to merge 6 commits intoopenfrontio:mainfrom
Caleb-Cohen:test/sam-refire
Draft

Test/sam refire#3350
Caleb-Cohen wants to merge 6 commits intoopenfrontio:mainfrom
Caleb-Cohen:test/sam-refire

Conversation

@Caleb-Cohen
Copy link

@Caleb-Cohen Caleb-Cohen commented Mar 4, 2026

Requested by Evan in Discord to review: here

Since this bypasses issues, I'm looking for a confirmation from a maintainer before I finish this PR. Its current state is just meant to demonstrate the MVP.

Description:

#3167 added SAM missile immunity to counter nuke/hydro & hydro/hydro strategies. As a result, large trade-maxing games can result in lengthy stalemates as clusters of high-level SAMs can be almost impenetrable.

#3223 added SAM missile re-targeting so SAMs will re-engage atomics whose initial interceptors were destroyed. This PR did not remove the invulnerability on the SAM interceptor.

This PR removes SAM interceptor invulnerability and adds communication to the attacker and defender that SAM interceptors have been destroyed and re-attempts.

This change will make interceptor destroying a viable strategy again, but it will be significantly nerfed compared to pre #3167 since there was a refire mechanic implemented in #3223.

Attached is a video showing the mechanic. First attack shows SAM engaging correctly on initial contact, second attack shows SAM re-engaging once the first interceptor was destroyed.

re-target_communication.1.mp4

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

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

calebcohen

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c0a9566d-5fad-4674-a5d8-3957745a91c9

📥 Commits

Reviewing files that changed from the base of the PR and between fb2ec45 and ee911f1.

📒 Files selected for processing (1)
  • src/core/configuration/DefaultConfig.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/configuration/DefaultConfig.ts

Walkthrough

Added two localization keys; changed nuke detonation to include SAM missiles; added a SAM refire-delay config and logic that delays retargeting, clears target SAM flags, and sends defender/attacker notifications when an interceptor is destroyed.

Changes

Cohort / File(s) Summary
Localization
resources/lang/en.json
Added two message keys: interceptor_destroyed and interceptor_destroyed_attacker.
Nuke detonation logic
src/core/execution/NukeExecution.ts
Removed UnitType.SAMMissile from the detonation exclusion so SAM interceptors can be affected by nuke explosions.
SAM interception handling
src/core/execution/SAMMissileExecution.ts
Added stateful refire-delay behavior: when an interceptor is destroyed while target remains active, initialize/decrement refireDelayRemaining, on expiry clear the target's SAM-target flag and send defender/attacker notifications, then deactivate the SAM.
Configuration
src/core/configuration/Config.ts, src/core/configuration/DefaultConfig.ts
Added samRefireDelayTicks() to the public config API; DefaultConfig returns 0 (beta placeholder).

Sequence Diagram

sequenceDiagram
    participant Attacker
    participant Nuke
    participant SAM as SAM_Interceptor
    participant Target
    participant Defender

    Attacker->>Nuke: Launch nuke at Target
    Defender->>SAM: Deploy interceptor toward Nuke
    SAM->>Nuke: Attempt interception
    Nuke->>SAM: Explosion / blast affects SAM
    alt SAM destroyed and Target still active
        SAM->>SAM: Start/consume refireDelayRemaining ticks
        SAM->>Target: (on delay expiry) Clear SAM-target flag
        SAM-->>Defender: Notify "Interceptor destroyed, retargeting {unit}"
        SAM-->>Attacker: Notify "{unit} survived interception, will re-attempt interception, if possible"
        SAM-->>SAM: Mark inactive / stop interception
    else SAM destroyed and Target gone
        SAM-->>SAM: Mark inactive / stop interception
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

⚡ An interceptor fell, a pause began,
A counter ticks before it can retarget again.
Flags cleared, two messages sent on the way,
Small keys added to note the fray.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Test/sam refire' is vague and uses the word 'Test' which suggests it may be a branch name rather than a descriptive PR title; it does not clearly convey the main change of removing SAM interceptor invulnerability. Consider using a more descriptive title like 'Remove SAM interceptor invulnerability and add refire notifications' to clearly summarize the main changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description is well-detailed and directly related to the changeset, explaining the context from previous PRs, the specific problem being addressed, and the implemented solution with a demonstration video.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/core/execution/SAMMissileExecution.ts (1)

42-61: Please add a regression test for the interceptor-destroyed branch.

This branch now changes targeting state and emits two player-facing messages. A focused test would protect against future regressions in refire flow and event text routing.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/execution/SAMMissileExecution.ts` around lines 42 - 61, Add a
regression test covering the interceptor-destroyed branch in
SAMMissileExecution: simulate an interceptor being destroyed so
this.target.isActive() is true, run the SAMMissileExecution flow, assert that
the target's setTargetedBySAM(false) behaviour occurs (target no longer flagged
as targeted by SAM) and verify mg.displayMessage was called twice with the
expected keys ("events_display.interceptor_destroyed" and
"events_display.interceptor_destroyed_attacker") and correct MessageType and
player ids (this._owner.id() and this.target.owner().id()); use spies/mocks for
mg.displayMessage and the target owner/id methods to validate messages and state
changes to prevent regressions in refire flow and event routing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/core/execution/SAMMissileExecution.ts`:
- Around line 54-60: The message emitted in SAMMissileExecution via
this.mg.displayMessage using key events_display.interceptor_destroyed_attacker
and MessageType.SAM_MISS implies a new interceptor is inbound even though the
code only clears the SAM-target flag; update the logic to avoid promising a
refire by either (a) changing the message key/text to neutral wording (e.g.,
"interceptor_destroyed" or "sam_target_cleared") in the same display call, or
(b) perform a real availability check on the attacker's launchers (use the
owner's launcher/launcherPool APIs or a canFire()/availableLauncher() check on
this.target.owner()) and only call this.mg.displayMessage with the existing key
when an actual interceptor launch is confirmed; modify SAMMissileExecution
accordingly to reference events_display.interceptor_destroyed_attacker,
this.mg.displayMessage, and this.target.owner().

---

Nitpick comments:
In `@src/core/execution/SAMMissileExecution.ts`:
- Around line 42-61: Add a regression test covering the interceptor-destroyed
branch in SAMMissileExecution: simulate an interceptor being destroyed so
this.target.isActive() is true, run the SAMMissileExecution flow, assert that
the target's setTargetedBySAM(false) behaviour occurs (target no longer flagged
as targeted by SAM) and verify mg.displayMessage was called twice with the
expected keys ("events_display.interceptor_destroyed" and
"events_display.interceptor_destroyed_attacker") and correct MessageType and
player ids (this._owner.id() and this.target.owner().id()); use spies/mocks for
mg.displayMessage and the target owner/id methods to validate messages and state
changes to prevent regressions in refire flow and event routing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5a5438c7-aa08-4308-b36e-e2b1b60ef60b

📥 Commits

Reviewing files that changed from the base of the PR and between e137fca and 717d3e4.

📒 Files selected for processing (3)
  • resources/lang/en.json
  • src/core/execution/NukeExecution.ts
  • src/core/execution/SAMMissileExecution.ts

@github-project-automation github-project-automation bot moved this from Triage to Development in OpenFront Release Management Mar 4, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 4, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/core/execution/SAMMissileExecution.ts (1)

43-67: Add focused regression tests for this timing branch.

This block is stateful and time-based; please add tests that verify delay countdown, single flag clear, and one-time message emission.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/execution/SAMMissileExecution.ts` around lines 43 - 67, The timing
branch in SAMMissileExecution that uses
refireDelayRemaining/refireDelayRemaining ??= and handles target.isActive(),
target.setTargetedBySAM(false), and mg.displayMessage(...) needs focused
regression tests: add tests that (1) initialize a SAMMissileExecution with a
live interceptor and verify refireDelayRemaining is set to
mg.config().samRefireDelayTicks() and counts down each tick until zero, (2)
assert target.setTargetedBySAM(false) is called exactly once when the delay
expires (not on intermediate ticks), and (3) assert mg.displayMessage is invoked
once for both "events_display.interceptor_destroyed" and
"events_display.interceptor_destroyed_attacker" only when the delay reaches
zero; use or mock methods isActive(), owner().id(), and
config().samRefireDelayTicks() to control timing and observe side effects.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/core/execution/SAMMissileExecution.ts`:
- Around line 43-67: The timing branch in SAMMissileExecution that uses
refireDelayRemaining/refireDelayRemaining ??= and handles target.isActive(),
target.setTargetedBySAM(false), and mg.displayMessage(...) needs focused
regression tests: add tests that (1) initialize a SAMMissileExecution with a
live interceptor and verify refireDelayRemaining is set to
mg.config().samRefireDelayTicks() and counts down each tick until zero, (2)
assert target.setTargetedBySAM(false) is called exactly once when the delay
expires (not on intermediate ticks), and (3) assert mg.displayMessage is invoked
once for both "events_display.interceptor_destroyed" and
"events_display.interceptor_destroyed_attacker" only when the delay reaches
zero; use or mock methods isActive(), owner().id(), and
config().samRefireDelayTicks() to control timing and observe side effects.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d10e17b5-1455-46e9-82ab-4a9a838c0e24

📥 Commits

Reviewing files that changed from the base of the PR and between 844b71a and fb2ec45.

📒 Files selected for processing (3)
  • src/core/configuration/Config.ts
  • src/core/configuration/DefaultConfig.ts
  • src/core/execution/SAMMissileExecution.ts

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 5, 2026
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.

1 participant