Miguzepinu

PiTRNG.lua

Apr 25th, 2017
213
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rng_address = 0x02060E06
  2. lucky_chance = 3 --(out of 100)
  3. lucky_chance_high = 6
  4. v_space = 9
  5. base = 6 --value x to display rng % x (number of enemies)
  6. Mario_target = 7 --#RNG value that determines Mario's target
  7. Luigi_target = 6 --#RNG value that determines Luigi's target
  8. target = 1 --# of target enemy (0-5)
  9. yorng = 43653
  10.  
  11. function BitAND(a,b)--Bitwise and
  12.     p,c = 1,0
  13.     while a>0 and b>0 do
  14.         local ra, rb = a%2, b%2
  15.         if ra+rb > 1 then
  16.             c = c+p
  17.         end
  18.         a, b, p = (a-ra)/2, (b-rb)/2, p*2
  19.     end
  20.     return c
  21. end
  22.  
  23. function nextRNG(seed)--RNG algorithm
  24.     return BitAND(math.floor(seed*20.5), 0x7fff) + seed%2*0x8000
  25. end
  26.  
  27. function fn()
  28.     rng = memory.readword(rng_address)--get current (most recently used) RNG
  29.     gui.text(0, -190, rng, "red")--display current RNG
  30.     frameFoundM = false
  31.     frameFoundL = false
  32.     for i = 1,20 do --for each next 20 RNG values
  33.         rng = nextRNG(rng)-- find next RNG value
  34.        
  35.         color = ""
  36.         if rng%100 < lucky_chance then
  37.             color = "#FFFF00"
  38.         elseif rng%100 < lucky_chance_high then
  39.             color = "#FFAA00"
  40.         end
  41.         gui.text(0, i*v_space-190, rng, color)
  42.         if rng == yorng then
  43.             gui.text(69, i*v_space-190, "yoooo")
  44.         end
  45.        
  46.         if base == 2 then
  47.             rngmod = rng%8/4
  48.         else
  49.             rngmod = rng%base
  50.         end
  51.         gui.text(250, (i-1)*v_space-190, rng%base)
  52.         gui.text(240, (Mario_target-1)*v_space-190, "M", "red")
  53.         if i >= Mario_target and rng%base == target and frameFoundM == false then
  54.             frameFoundM = true
  55.             gui.text(244, 0, i-Mario_target, "red")
  56.         end
  57.         gui.text(240, (Luigi_target-1)*v_space-190, "L", "green")
  58.         if i >= Luigi_target and rng%base == target and frameFoundL == false then
  59.             frameFoundL = true
  60.             gui.text(244, 10, i-Luigi_target, "green")
  61.         end
  62.     end
  63. end
  64.  
  65. gui.register(fn)
RAW Paste Data