Prevent variable-cost spells being made free with very small inputs - #1308
Open
Robotgiggle wants to merge 5 commits into
Open
Robotgiggle wants to merge 5 commits into
Robotgiggle wants to merge 5 commits into
Conversation
s5bug
approved these changes
Sep 23, 2026
| RenderedSpell { | ||
| override fun cast(env: CastingEnvironment) { | ||
| if (duration > 1.0 / 20.0) { | ||
| if (duration >= 1.0 / 20.0) { |
Contributor
There was a problem hiding this comment.
Why was this originally a >?
Member
Author
There was a problem hiding this comment.
Honestly, no idea. Might have just been an oversight from whoever originally wrote it, since the intent seems to pretty clearly be "minimum duration of 1 tick".
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds a new
toLongNonzero()method to convert a Double to a Long while ensuring the output is at minimum 1. This is used to prevent spells with costs based on player input (Impulse, Blink, Explode/Fireball, Anchorite/Wayfarer, and the Zeniths/Nadirs) from being made free by providing an input value so small it gets rounded to zero when converted to a Long.This also makes those spells have a nonzero cost even when the input value actually is zero, since there is still a world interaction in that case and thus the spell should not be infinitely spammable for free.
Also, entirely unrelated to the cost clamping, this PR fixes #941 - I was changing stuff in OpPotion anyway, so I figured I'd toss in a fix here rather than making a separate PR for a single-character change.