Added universal RNGNext function

This commit is contained in:
Wofsauge committed 2022-06-13 19:57:08 +02:00
1 parent b670249687
commit b1f2644979
2 files changed
+20 -20

No files matched your search

+18 -9
View File
@@ -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