Skip to content

fix(castle-siege): prevent teleporting over a closed gate - #1350

Open
icheat2win wants to merge 5 commits into
MUnique:masterfrom
icheat2win:fix/castle-siege-teleport-over-gates
Open

icheat2win wants to merge 5 commits into
MUnique:masterfrom
icheat2win:fix/castle-siege-teleport-over-gates

Conversation

@icheat2win

Copy link
Copy Markdown
Contributor

Part of the Castle Siege epic (#735).

Problem

WizardTeleportAction had a todo: "During castle siege, can't teleport over the non-destroyed gates". Attackers could teleport past a closed gate into the castle.

Change

  • New plugin point IPlayerTeleportRestrictionPlugIn (fresh GUID). Teleport and Teleport Ally ask it before consuming mana and moving the player; the todo is removed.
  • CastleSiegeNpcController.IsLineBlockedByClosedGate: walks the straight line from start to target (one tile per row/column, so it can't skip the two gate rows) and checks it against the reference-counted gate terrain the controller already keeps. That terrain is exactly the closed gates, so opened (lever) and destroyed gates no longer block.
  • CastleSiegePlugIn implements the point on the Castle Siege map.
  • Documented on the Castle Siege page.

The todo suggested a "simple y-axis check". I used the line-through-gate check instead because a pure y check would also block teleports far beside the gate. Note that teleports over the castle walls are not blocked; that's general teleport behaviour (only the target tile is checked) and out of scope here.

Tests

New CastleSiegeTeleportTests (9 tests): straight/diagonal/both directions over the gate, beside it, in front of it, same tile, opened gate, and the plugin on and off the siege map.

Ran the full MUnique.OpenMU.Tests suite with --no-build: 2451 passed, 2 skipped. Not verified with a game client.


Generated by Claude Code

Adds the IPlayerTeleportRestrictionPlugIn point, which the Teleport and
Teleport Ally skills ask before moving a player. The Castle Siege plugin
uses it to stop teleports whose line crosses a closed gate, and the old
todo in WizardTeleportAction is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011xNc764bgrPZRQYCRzPj1x
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-29T16:11:20.603273Z
We couldn’t complete this review. Comment @codex review to try again.
ddb913a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codacy-production

codacy-production Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 36 complexity · 7 duplication

Metric Results
Complexity 36
Duplication 7

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@sven-n sven-n left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changes requested: src/GameLogic/CastleSiege/CastleSiegeNpcController.cs:225-246 rounds one tile per step with Math.Round, which is not a supercover line traversal. Reversing a segment can sample different tiles, allowing a teleport across a closed gate in one direction but not the other. For example, with gate tiles X=90–95, Y=100–101, (85,99)->(91,102) samples (90,101), while the reverse can miss the blocked tiles. Please use supercover traversal or exact segment/tile intersection and add reverse-direction and corner-crossing tests. An action-level test for Teleport and Teleport Ally would also help.

…teleport-over-gates

# Conflicts:
#	docs-website/docs/server-features/castle-siege.md
#	src/GameLogic/CastleSiege/CastleSiegePlugIn.cs
Walk the line between the tile centers as a supercover, so the result is the
same in both directions and a corner touch of a closed gate tile also blocks.
Add reverse-direction, corner and action-level tests for Teleport and
Teleport Ally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011xNc764bgrPZRQYCRzPj1x
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011xNc764bgrPZRQYCRzPj1x

This branch has not been deployed

No deployments
Sign up for free to 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.

3 participants