WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@alexalexmax
Copy link
Contributor

@alexalexmax alexalexmax commented Dec 9, 2025

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

🆑

  • fix: The scram implanter now teleports you within a 100 tile radius, as originally intended, and will not teleport you into open space.

@PJBot PJBot added S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. 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. labels Dec 9, 2025
@Ilya246
Copy link
Contributor

Ilya246 commented Dec 9, 2025

i've been told this uses some of my goob code so i say licensing is ok

@alexalexmax alexalexmax mentioned this pull request Dec 9, 2025
2 tasks
@PJBot PJBot added S: Awaiting Changes Status: Changes are required before another review can happen and removed S: Needs Review Status: Requires additional reviews before being fully accepted. Not to be replaced by S: Approved. labels Dec 10, 2025
@iaada iaada added T: Bugfix Type: Bugs and/or bugfixes P3: Standard Priority: Default priority for repository items. T: Cleanup Type: Code clean-up, without being a full refactor or feature D3: Low Difficulty: Some codebase knowledge required. A: General Interactions Area: General in-game interactions that don't relate to another area. and removed S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. labels Dec 10, 2025
@alexalexmax alexalexmax requested a review from iaada December 11, 2025 00:33
@PJBot PJBot added S: Needs Review Status: Requires additional reviews before being fully accepted. Not to be replaced by S: Approved. and removed S: Awaiting Changes Status: Changes are required before another review can happen labels Dec 11, 2025
@alexalexmax
Copy link
Contributor Author

changes applied

Copy link
Member

@iaada iaada left a 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.

@PJBot PJBot added the S: Approved Status: Reviewed and approved by at least one maintainer; a PR may require another approval. label Dec 11, 2025
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scram implant logic needs to be rewritten scram implant's range is way lower than intended

4 participants