I haven't seen this mentioned in this thread so forgive me if this is known or being passed around. I've been playing with manipulating things in OoA for a while too just to make my game simpler. I found where the RNG is and how it's generated and how to predict what it will be.
It's stored as a word at 0xFF94 and is generated like this:
now = [0XFF94]
next = (now * 3) AND 0xFF00
next += ( ( (next >> 8) and 0xFF) + (current AND 0xFF) ) AND 0xFF
in lua script it's like this:
next = bit.band( current * 3, 0XFF00 )
next = next + bit.band( bit.rshift( next, 8 ) + bit.band( current, 0xFF ), 0xFF )
-Sword swipes and shovel digs do this once.
-Monsters call this twice. I'm assuming for a new direction and a distance of travel.
-If the current value meets some condition when an enemy dies or pot is lifted or dirt is dug, an item will be dropped. Another call determines what is dropped (so one step when you dig and find nothing, two steps if you dig and find something).
-Keese call this every other frame so if there are Keese in the screen then chances are manipulating will be difficult while they're roaming around.
-Maple calls this once when her shadow appears and once when she appears. She then calls this 15 different times to see what gets dropped.
-Moving to a new room does this 256 times regardless of the contents of the new room. I think things like enemy positions and facing direction are decided here.
I've yet to find what any values do under different conditions (maple drops, gasha seed items, etc). I DO know that a value of 0x00D8 will dig up a huge rupee. :)
I have a little LUA script to tell me what the next relevant values will be.
Language: lua
function DEC_HEX(IN)
local B,K,OUT,I,D=16,"0123456789ABCDEF","",0
while IN>0 do
I=I+1
IN,D=math.floor(IN/B),math.mod(IN,B)+1
OUT=string.sub(K,D,D)..OUT
end
return string.sub( "0000" .. OUT, -4 )
end
function get_next( now, iteration )
if iteration > 257 then
return
end
next = bit.band( now * 3, 0XFF00 )
next = next + bit.band( bit.rshift( next, 8 ) + bit.band( now, 0xFF ), 0xFF )
if iteration == 1 then
print( "Sword swing/shovel use: "..DEC_HEX( next ) )
elseif iteration == 2 then
print( "Monster Action/dug up item: "..DEC_HEX( next ) )
elseif iteration == 3 then
print( "Dropped Item: "..DEC_HEX( next ) )
elseif iteration == 256 then
print( "New Area: "..DEC_HEX( next ) )
end
get_next( next, iteration + 1)
end
local next
local now
next = 2 --to prevent nil comparison when the script starts
while true do
now = memory.readword( 0xFF94 )
if now ~= next then
print( "Currently: " .. DEC_HEX( now ) )
get_next( now, 1 )
next = now
print( "===================" )
end
vba.frameadvance()
end
I don't know how to clear the console so it's constantly adding text every time the RNG changes per frame (room changes will usually show two or three changes since it's displaying per frame).
Hopefully, someone will find this useful.