Fix spectral card RNG parity with vanilla Balatro#1231
Open
liafonx wants to merge 2 commits intoSteamodded:mainfrom
Open
Fix spectral card RNG parity with vanilla Balatro#1231liafonx wants to merge 2 commits intoSteamodded:mainfrom
liafonx wants to merge 2 commits intoSteamodded:mainfrom
Conversation
- Add sort_id to SMODS.Suit (vanilla: S=1,H=2,D=3,C=4) and SMODS.Rank (vanilla: 2=1..Ace=13) so pseudorandom_element iterates in the same order as vanilla integer-keyed arrays; custom suits/ranks auto-assign sort_id >= 5 / >= 14 via a shared max_sort_id counter - Swap c_familiar and c_incantation to draw rank before suit, matching vanilla call order; fixes downstream RNG shift on seeded runs
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.
Problem
SMODS overrides spectral consumables to support custom suits/ranks, but diverges from vanilla RNG in two ways:
Pool sort order —
pseudorandom_elementsorts bysort_idwhen present, falling back to key order. Vanilla suits/ranks use integer-keyed arrays (Spades=1, Hearts=2, Diamonds=3, Clubs=4; 2=1…Ace=13). SMODS uses string-keyed tables with nosort_id, so the fallback sorts alphabetically — a different order which breaks seeded results.Call order in
c_familiar/c_incantation— vanilla draws rank first then suit; the SMODS override drew suit first then rank, reversing the two RNG calls.Fix
Single file:
src/game_object.luaFix 1 — sort order (restores RNG parity for
c_sigil,c_ouija, and all spectral cards):max_sort_idcounter toSMODS.Suit(init4) andSMODS.Rank(init13).registerauto-assignssort_idfrom the counter if not set — custom suits/ranks append after vanilla (≥ 5/≥ 14).sort_idmatching their vanilla integer-key positions.Fix 2 — call order (further restores parity for
c_familiarandc_incantation):_rank, _suitassignment so rank RNG fires before suit, matching vanilla.c_grimis unaffected (rank hardcoded'A'; only stale TODO removed).Testing
Tested with seeded runs — all five spectral cards (
c_grim,c_familiar,c_incantation,c_sigil,c_ouija) produce identical outcomes to unmodded Balatro with the same seed.Compatibility
No API change.
sort_idis additive; mods that don't set it get auto-assigned values appended after vanilla. No new Lovely patches required.Additional Info:
I didn't modify api's
I didn't modify api's or I've updated lsp definitions.
I didn't make new lovely files or all new lovely files have appropriate priority.