-
Notifications
You must be signed in to change notification settings - Fork 4.8k
ScramOnTrigger teleportation logic rewrite #41808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alexalexmax
wants to merge
9
commits into
space-wizards:master
Choose a base branch
from
alexalexmax:scram-rework
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+31
−77
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
|
i've been told this uses some of my goob code so i say licensing is ok |
iaada
requested changes
Dec 10, 2025
Co-authored-by: āda <[email protected]>
Co-authored-by: āda <[email protected]>
Contributor
Author
|
changes applied |
iaada
approved these changes
Dec 11, 2025
Member
iaada
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and it works well! Thanks for catching this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A: General Interactions
Area: General in-game interactions that don't relate to another area.
D3: Low
Difficulty: Some codebase knowledge required.
P3: Standard
Priority: Default priority for repository items.
S: Approved
Status: Reviewed and approved by at least one maintainer; a PR may require another approval.
S: Needs Review
Status: Requires additional reviews before being fully accepted. Not to be replaced by S: Approved.
size/M
Denotes a PR that changes 100-999 lines.
T: Bugfix
Type: Bugs and/or bugfixes
T: Cleanup
Type: Code clean-up, without being a full refactor or feature
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About the PR
Rewrote logic in ScramOnTrigger, specifically the SelectRandomTileInRange method.
Supersedes #41786
Why / Balance
Resolves #41785
Resolves #31480
This reworks the scram teleportation logic.
This is because the previous logic had multiple fundamental flaws that were not solvable.
It also introduced several hard-to-pinpoint bugs.
It also disproportionally weighed small grids compared to larger ones.
It also did not teleport the user in a circle with a given radius but instead teleported the user in a square which used the rotation of the map and not the current grid.
It also did not solve the issue of teleporting into space.
It also did not correctly find non-space tiles.
It also did not use the correct formula for calculating the side length of the largest square that fits inside a circle.
It also had a terrible runtime complexity, with a worst-case runtime being at least 20000 operations due enumerating through every tile within range and a combination of the square it used to check for valid teleportation tiles not being lined up with the map and a bug that made it always find the bounding square to be completely filled with tiles. Luckily this never occurred in practice because the error in the formula for calculating the side length of the largest square that fits inside a circle made the volume of the bounding square 1% of the the intended volume.
Given the sheer quantity of issues I opted for a rewrite.
Technical details
SelectRandomTileInRange has been mostly rewritten.
The method now makes a series of attempts at finding a random empty non-space tile within a certain radius, and returns null if no tile is found.
On each attempt, a random distance from 0 to radius is calculated(trending towards the upper range), which is then shrunk down based on the current attempt count. This means later attempts will look for areas closer to the player. This is primarily so that the method does not fail more frequently on smaller stations.
A random target coordinate vector is calculated by multiplying the previously attained distance by a random angle.
We check if the tile at the target coordinate vector exists, is not space, and is not blocked. If the check passes, we stop running attempts and return the coordinates.
If every attempt fails, null is returned.
Media
scram_rewrite.mp4
Requirements
Changelog
🆑