User File #15492255327748684

Upload All User Files

#15492255327748684 - dig

dig.lua
791 downloads
Uploaded 6/20/2014 4:19 PM by SBD (see all 61)
--[[This script will tell you what item will drop from the ground if you dig in either of the Zelda Oracle games.
    It assumes that the RN doesn't change during the five frames after you press the shovel button so it might not work if there are enemies on screen.
    This will NOT work if you remove a dirt pile or snow or if you dig during the Miniboss fight in Lv.3 in OoA. ]]
----
--drop:          1/4
----
--Heart:         5/16
--1 Rupee:       13/32
--5 Rupees:      1/8
--Fairy:         1/16
--Bombs:         0
--Ember Seeds:   0
--Mystery Seeds: 0
--Scent Seeds:   0
--Pegasus Seeds: 0
--Gale Seeds:    0
--Rope:          63/2048
--Beetle:        105/2048
--100 Rupees:    3/256
----




local function RNG (low,high)

  low=3*low
  if high>85 then low=low+1 end
  if high>170 then low=low+1 end 
  if low>255 then low=low-256 end
  if low>255 then low=low-256 end
  high=high+low
  if high>255 then high=high-256 end

  return low, high
end


memory.usememorydomain("HRAM")


while true do

  local low0,high0 = memory.readbyte (0x0015), memory.readbyte (0x0014)
  local low1,high1 = RNG (low0,high0)
  local low2,high2 = RNG (low1,high1)
  local low3,high3 = RNG (low2,high2)
  local lh1 = high1%64
  local lh2 = high2%32
  local lh3 = high3%16


  if lh1== 3 or lh1==12 or lh1==14 or
     lh1==16 or lh1==19 or lh1==26 or lh1==29 or
     lh1==35 or lh1==39 or lh1==40 or lh1==47 or
     lh1==52 or lh1==53 or lh1==55 or lh1==57 or lh1==60

--Checks IF an item is dropped.
--In the following table values that will trigger
--an item drop are marked with an "x".
--00    40    ...
--01    41    ...
--02    42    ...
--03 x  43 x  ...
--04    44    ...
--05    45    ...
--06    46    ...
--07    47    ...
--08    48    ...
--09    49    ...
--0A    4A    ...
--0B    4B    ...
--0C x  4C x  ...
--0D    4D    ...
--0E x  4E x  ...
--0F    4F    ...
--10 x  50 x  ...
--11    51    ...
--12    52    ...
--13 x  53 x  ...
--14    54    ...
--15    55    ...
--16    56    ...
--17    57    ...
--18    58    ...
--19    59    ...
--1A x  5A x  ...
--1B    5B    ...
--1C    5C    ...
--1D x  5D x  ...
--1E    5E    ...
--1F    5F    ...
--20    60    ...
--21    61    ...
--22    62    ...
--23 x  63 x  ...
--24    64    ...
--25    65    ...
--26    66    ...
--27 x  67 x  ...
--28 x  68 x  ...
--29    69    ...
--2A    6A    ...
--2B    6B    ...
--2C    6C    ...
--2D    6D    ...
--2E    6E    ...
--2F x  6F x  ...
--30    70    ...
--31    71    ...
--32    72    ...
--33    73    ...
--34 x  74 x  ...
--35 x  75 x  ...
--36    76    ...
--37 x  77 x  ...
--38    78    ...
--39 x  79 x  ...
--3A    7A    ...
--3B    7B    ...
--3C x  7C x  ...
--3D    7D    ...
--3E    7E    ...
--3F    7F    ...

  then



    if lh2<=2 then

        if high3>=224 then drop = "100 Rupees"
        elseif lh3<=2 or (lh3>=8 and lh3<=10) then drop = "Rope"
        else drop = "Beetle" end


    elseif(lh2>=3 and lh2<=11) or lh2==23 then drop = "Heart"
    elseif lh2>=25 and lh2<=28  then drop = "5 Rupees"
    elseif lh2>=30 then drop = "Fairy"
    else drop = "1 Rupee"
    end

--Checks WHAT is dropped.
--"r" = 1 Rupee, "R" = 5 Rupees, "H" = Heart, "F" = Fairy
--Values marked with "?" trigger a third check (see next table).
--
--00 ?  20 ?  ...
--01 ?  21 ?  ...
--02 ?  22 ?  ...
--03 H  23 H  ...
--04 H  24 H  ...
--05 H  25 H  ...
--06 H  26 H  ...
--07 H  27 H  ...
--08 H  28 H  ...
--09 H  29 H  ...
--0A H  2A H  ...
--0B H  2B H  ...
--0C r  2C r  ...
--0D r  2D r  ...
--0E r  2E r  ...
--0F r  2F r  ...
--10 r  30 r  ...
--11 r  31 r  ...
--12 r  32 r  ...
--13 r  33 r  ...
--14 r  34 r  ...
--15 r  35 r  ...
--16 r  36 r  ...
--17 H  37 H  ...
--18 r  38 r  ...
--19 R  39 R  ...
--1A R  3A R  ...
--1B R  3B R  ...
--1C R  3C R  ...
--1D r  3D r  ...
--1E F  3E F  ...
--1F F  3F F  ...
--
--
--"?"-Table
--"B" = Beetle, "R" = Rope, "$" = 100 Rupees
--
--00 R  10 R  ... D0 R  E $  F $
--01 R  11 R  ... D1 R  E $  F $
--02 R  12 R  ... D2 R  E $  F $
--03 B  13 B  ... D3 B  E $  F $
--04 B  14 B  ... D4 B  E $  F $
--05 B  15 B  ... D5 B  E $  F $
--06 B  16 B  ... D6 B  E $  F $
--07 B  17 B  ... D7 B  E $  F $
--08 R  18 R  ... D8 R  E $  F $
--09 R  19 R  ... D9 R  E $  F $
--0A R  1A R  ... DA R  E $  F $
--0B B  1B B  ... DB B  E $  F $
--0C B  1C B  ... DC B  E $  F $
--0D B  1D B  ... DD B  E $  F $
--0E B  1E B  ... DE B  E $  F $
--0F B  1F B  ... DF B  E $  F $





  else drop = "-"
  end


  gui.text(0,16,drop)
  emu.frameadvance()
end