diff --git a/eid_api.lua b/eid_api.lua index 27c2795e..df92363c 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -1055,17 +1055,11 @@ end -- Didn't seem right to put them in main or eid_modifiers local numVoidable = 0 local numRunable = 0 -local function VoidRNGNext(num) - num = num ~ ((num >> 5) & 4294967295) - num = num ~ ((num << 9) & 4294967295) - num = num ~ ((num >> 7) & 4294967295) - return num >> 0; -end local function GetTwoIncreases(rng, tbl) local statTable = {1,2,3,4,5,6} -- perform 5 random swaps of our stat table for i = 6, 2, -1 do - rng = VoidRNGNext(rng) + rng = EID:RNGNext(rng, 5, 9, 7) local result = (rng % i) + 1 local temp = statTable[i] statTable[i] = statTable[result] @@ -1103,14 +1097,13 @@ end -- Determine what stats will be increased after 1 absorption, the whole room's absorption, and whole room + a purchased item above your head function EID:VoidRNGCheck(player, isRune) local increases = {0, 0, 0, 0, 0, 0} - local shopItemIncreases = {}; local singleIncreases = {} local startRNG = (isRune and player:GetCardRNG(Card.RUNE_BLACK):GetSeed()) or player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_VOID):GetSeed() local count = (isRune and numRunable) or numVoidable local eidTable = (isRune and EID.BlackRuneStatIncreases) or EID.VoidStatIncreases -- in Repentance, an additional RNG call is done before the 5 for stat ups when using Void - if REPENTANCE and not isRune then startRNG = VoidRNGNext(startRNG) end + if REPENTANCE and not isRune then startRNG = EID:RNGNext(startRNG, 5, 9, 7) end for i = 1, count do startRNG = GetTwoIncreases(startRNG, increases) if i == 1 then eidTable[3] = {table.unpack(increases)} end @@ -1716,3 +1709,19 @@ end function EID:AddIconToObject(eType, eVariant, eSubType, iconName) EID.ObjectIcon[eType.."."..eVariant.."."..eSubType] = EID.InlineIcons[iconName] end + +-- reimplementation of RNG Seed shift feature used by the game. Mostly used for RNG Prediction features +function EID:RNGNext(rngNum, shift1, shift2, shift3) + rngNum = rngNum ~ ((rngNum >> shift1) & 4294967295) + rngNum = rngNum ~ ((rngNum << shift2) & 4294967295) + rngNum = rngNum ~ ((rngNum >> shift3) & 4294967295) + return rngNum >> 0; +end + +-- General RNG functions for RNG predicting +function EID:SeedToFloat(seed) + local multi = 2.3283061589829401E-10; + return seed * multi; +end + +end \ No newline at end of file diff --git a/eid_bagofcrafting.lua b/eid_bagofcrafting.lua index 769afb19..e73dc53f 100644 --- a/eid_bagofcrafting.lua +++ b/eid_bagofcrafting.lua @@ -217,18 +217,9 @@ local recheckPickups = false local customRNGSeed = 0x77777770 local customRNGShift = {0,0,0} -local function RNGNext() - local num = customRNGSeed - num = num ~ ((num >> customRNGShift[1]) & 4294967295) - num = num ~ ((num << customRNGShift[2]) & 4294967295) - num = num ~ ((num >> customRNGShift[3]) & 4294967295) - customRNGSeed = num >> 0; - return customRNGSeed; -end - local function nextFloat() local multi = 2.3283061589829401E-10; - return RNGNext() * multi; + return EID:RNGNext(customRNGSeed, customRNGShift[1], customRNGShift[2], customRNGShift[3]) * multi; end -- Convert a pickup's ID into what ingredient it counts as @@ -387,7 +378,7 @@ function EID:calculateBagOfCrafting(componentsTable) compCounts[compId + 1] = compCounts[compId + 1] + 1 compTotalWeight = compTotalWeight + pickupValues[compId + 1] customRNGShift = componentShifts[compId + 1] - RNGNext() + EID:RNGNext(customRNGSeed, customRNGShift[1], customRNGShift[2], customRNGShift[3]) end customRNGShift = componentShifts[7]