Skip to content

fix: report downed patrol helicopters as crashes and off-map markers by direction - #77

Merged
HandyS11 merged 11 commits into
developfrom
feat/heli-crash-offmap-directions
Aug 10, 2026
Merged

fix: report downed patrol helicopters as crashes and off-map markers by direction#77
HandyS11 merged 11 commits into
developfrom
feat/heli-crash-offmap-directions

Conversation

@HandyS11

Copy link
Copy Markdown
Owner

Fixes two defects in live map-event reporting.

1. A downed patrol helicopter was reported as having left

Every patrol-helicopter marker removal classified as HeliLeft ("🚁 Patrol Helicopter left (D7)"). The marker disappears for two very different reasons: the heli was shot down, or it finished its patrol and flew off the map edge. The shoot-down case is the one players care about — it marks loot on the ground — and it was indistinguishable from a routine departure.

Now the split is position-based, with a one-cell (146.25 unit) tolerance band:

  • vanishes inside the map → HeliCrashed → "🚁 Patrol Helicopter probably crashed at N13"
  • vanishes at or beyond the border → HeliLeft → "🚁 Patrol Helicopter left the map to the west"

The band exists because marker positions are sampled by polling, so a heli that has just crossed the border is usually still reported slightly inside it. A strict inside/outside test would misreport most routine departures as crashes.

2. Off-map markers reported a fake grid cell

MapGrid.LabelFor clamps out-of-world coordinates to the nearest edge cell. Cargo ships, helicopters and chinooks spawn in the ocean outside the playable world, so their spawn announcement named a cell they are not in and may never visit.

Those positions now render as an 8-point compass direction from the world centre, across announcements, team-chat lines, commands and the #info embed:

BeforeAfter
Ocean cargo spawn🚢 Cargo Ship entered at A0🚢 Cargo Ship entered from the north-east
!heli off-mapPatrol Helicopter at AB0 (5m ago)Patrol Helicopter to the north-east (5m ago)
#info events rowOut · AB0 · 3m agoOut · north-east · 3m ago

Approach

  • MapGrid gains DirectionFrom (bearing from the world centre, binned into 45° sectors centred on each compass point), IsOutsideWorld, and IsAtOrBeyondBorder.
  • New MapLocation.Describe / DescribeDirection return the location text plus whether it names a direction. Renderers append .dir to the message key when it does.
  • Nothing is repurposed: the existing "left" values keep their wording and now render only when map dimensions are unavailable, preserving today's raw-coordinate behaviour on that path.
  • 29 new resource keys per language. French direction words carry their article (l'est, le nord-est) so one message value covers all eight without an elision problem.

Verification

dotnet test RustPlusBot.slnx1315 passed, 1 skipped (1269 before this branch; +46 tests). Build clean under TreatWarningsAsErrors.

MapEventKind is not persisted anywhere, so appending HeliCrashed = 5 cannot affect stored state.

Spec: docs/superpowers/specs/2026-08-10-patrol-heli-crash-and-offmap-directions-design.md
Plan: docs/superpowers/plans/2026-08-10-patrol-heli-crash-and-offmap-directions.md

🤖 Generated with Claude Code

HandyS11and others added 11 commits August 10, 2026 18:55
Report a patrol helicopter that disappears inside the map as a probable
crash with its grid cell, and one that disappears at or beyond the border
as having left toward a compass direction. Replace clamped edge-cell grid
references for off-map markers with 8-point directions across cargo, heli
and chinook announcements, commands and the #info embed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Route MapEventKind.HeliCrashed in EventsCommandHandler through
GridReference.From directly, mirroring EventEmbedRenderer.Locate, so a
future out-of-bounds crash can never resolve the nonexistent
"command.event.helicrashed.dir" key. Also fixes an accent
inconsistency in the French heli entered/left strings, adds test
coverage for the border band's east/south edges and the classifier's
WorldSize == 0 guard, and documents the small-world edge case on
MapGrid.IsAtOrBeyondBorder.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The outer band of a Rust map is ocean, so a helicopter downed there leaves
no lootable debris and its grid cell would name water. The band erring
toward "left" costs nothing players can act on.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Field declarations to the top of their class and one wrapped parameter
list, per the pre-push formatter.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
CopilotAI lite review requested due to automatic review settings August 10, 2026 18:15

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes two live map-event reporting defects by (1) distinguishing patrol-helicopter “left” vs “crashed” based on last known position relative to a one-cell border band, and (2) rendering off-map marker locations as compass directions (localized) instead of clamped grid cells. This aligns event/command outputs with player expectations while preserving the existing “raw coordinates” fallback when map dimensions are unavailable.

Changes:

  • Add map-math helpers (IsOutsideWorld, IsAtOrBeyondBorder, DirectionFrom) plus a new MapDirection enum and localized direction words.
  • Introduce MapLocation formatting and apply it across event embeds/lines, commands, and the #info events embed so off-map locations become directions.
  • Split patrol heli marker removals into HeliCrashed vs HeliLeft and add corresponding localized resource keys and tests.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
tests/RustPlusBot.Localization.Tests/StringsResourceParityTests.csUpdates expected localization key count to reflect new .dir/direction/crash keys.
tests/RustPlusBot.Features.Events.Tests/Rendering/EventEmbedRendererTests.csAdds coverage for crash vs left wording and off-map direction rendering in embeds/lines.
tests/RustPlusBot.Features.Events.Tests/Messages/ServerEventsMessageRendererTests.csEnsures #info events rows show compass directions for off-map markers.
tests/RustPlusBot.Features.Events.Tests/Formatting/MapLocationTests.csNew tests for MapLocation grid-vs-direction behavior and localization.
tests/RustPlusBot.Features.Events.Tests/Classifying/MarkerEventClassifierTests.csAdds tests for heli removal classification (crash vs left) including null/zero dimensions fallback.
tests/RustPlusBot.Features.Commands.Tests/Handlers/EventHandlersTests.csVerifies command outputs (!heli, !events) render directions and crash messages correctly.
tests/RustPlusBot.Abstractions.Tests/Connections/MapGridTests.csAdds tests for compass binning and border/outside-world predicates.
src/RustPlusBot.Localization/Strings.resxAdds English direction words and .dir/crash message variants.
src/RustPlusBot.Localization/Strings.fr.resxAdds French direction words (with articles) and .dir/crash message variants.
src/RustPlusBot.Features.Events/Rendering/EventEmbedRenderer.csRoutes embed and line rendering through MapLocation + .dir key suffixing; adds crash kind support.
src/RustPlusBot.Features.Events/Messages/ServerEventsMessageRenderer.csUses MapLocation.Describe for active marker rows so off-map locations become directions.
src/RustPlusBot.Features.Events/Formatting/MapLocation.csNew formatter returning (text, isDirection) to drive .dir suffix selection consistently.
src/RustPlusBot.Features.Events/Classifying/MarkerEventClassifier.csSplits patrol heli removals into crash vs left using IsAtOrBeyondBorder.
src/RustPlusBot.Features.Events/Classifying/MapEventKind.csAdds HeliCrashed = 5.
src/RustPlusBot.Features.Commands/Handlers/MarkerReply.csUpdates marker commands to use .dir variants when location is a direction.
src/RustPlusBot.Features.Commands/Handlers/EventsCommandHandler.csUpdates !events rendering to use .dir variants and handle HeliCrashed.
src/RustPlusBot.Abstractions/Connections/MapGrid.csAdds outside-world check, border-band predicate, and 8-way bearing binning.
src/RustPlusBot.Abstractions/Connections/MapDirection.csNew enum ordered clockwise from north to support direct binning.
README.mdUpdates feature description to document crash reporting + off-map direction behavior.
docs/superpowers/specs/2026-08-10-patrol-heli-crash-and-offmap-directions-design.mdNew design spec documenting requirements and decisions.
docs/superpowers/plans/2026-08-10-patrol-heli-crash-and-offmap-directions.mdNew implementation plan capturing tasks, constraints, and verification steps.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@HandyS11
HandyS11 merged commit 4d5c78c into developAug 10, 2026
4 checks passed
@HandyS11
HandyS11 deleted the feat/heli-crash-offmap-directions branch August 10, 2026 18:24
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@HandyS11