Advertisement
Guest User

Untitled

a guest
May 10th, 2014
1,121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mdword=memory.readdwordunsigned
  2. mbyte=memory.readbyte
  3. rshift=bit.rshift
  4.  
  5. -- Initialize on Script Startup
  6. local frame = 0
  7. local iframe = 0
  8. local seed = 0
  9. local initial = 0
  10.  
  11. memory.registerwrite(0x021D15AC, function() frame = frame + 1 end)
  12. memory.registerwrite(0x0210F6CC, function() iframe = iframe + 1 end)
  13.  
  14. function buildseed()
  15. delay=mdword(0x021D1138)
  16. timehex=mdword(0x023FFDEC)
  17. datehex=mdword(0x023FFDE8)
  18. hour=string.format("%02X",(timehex%0x100)%0x40) -- memory stores as decimal, but Lua reads as hex. Convert.
  19. minute=string.format("%02X",(rshift(timehex%0x10000,8)))
  20. second=string.format("%02X",(mbyte(0x02FFFDEE)))
  21. year=string.format("%02X",(mbyte(0x02FFFDE8)))
  22. month=string.format("%02X",(mbyte(0x02FFFDE9)))
  23. day=string.format("%02X",(mbyte(0x02FFFDEA)))
  24. ab=(month*day+minute+second)%256 -- Build Seed
  25. cd=hour
  26. cgd=delay%65536 +1 -- can tweak for calibration
  27. abcd=ab*0x100+cd
  28. efgh=(year+cgd)%0x10000
  29. nextseed=ab*0x1000000+cd*0x10000+efgh -- Seed is built
  30. return nextseed
  31. end
  32.  
  33. function main()
  34. currseed = mdword(0x021D15A8)
  35. seed = mdword(0x021D15AC)
  36.  
  37. -- Detect initial seeding
  38. if mdword(0x021D15AC) == currseed then
  39. initial = mdword(0x021D15A8)
  40. if currseed ~= 0x00000000 then
  41. iframe = 0
  42. frame = 0
  43. end
  44. end
  45. if mdword(0x021D15A8) == 0 then -- if seed is 0, reset everything
  46. iframe = 0
  47. frame = 0
  48. end
  49.  
  50. -- Print variables in corner of bottom screen
  51. if frame == 0 then
  52. gui.text(0,-10,string.format("Next Seed: %08X", buildseed()))
  53. end
  54. gui.text(0,180,string.format("Initial Seed: %08X", initial))
  55. gui.text(0,170,string.format("Current Seed: %08X", currseed))
  56. gui.text(0,160,string.format("IRNG Frame: %d", iframe))
  57. gui.text(0,150,string.format("PRNG Frame: %d", frame))
  58. gui.text(0,140,string.format("Delay: %d", mdword(0x021D1138)))
  59. end
  60.  
  61. gui.register(main)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement