Advertisement
Guest User

earthbound / mother 2 lua script

a guest
Jul 19th, 2010
2,617
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. local RNG24 = {}
  2. local RNG26 = {}
  3. local RNG = {}
  4. local bit = 0
  5. local RNGoffset = -70
  6. local RNGend = 14592
  7. local RNGpos = -70
  8. RNG24[RNGoffset] = 4660
  9. RNG26[RNGoffset] = 120
  10. RNG[RNGoffset] = 134
  11.  
  12. for i=RNGoffset+1,RNGend do
  13. RNG24[i] = math.floor((RNG24[i-1]+bit)/2)+32768*math.fmod(RNG24[i-1]+bit,2)
  14. RNG26[i] = math.fmod(RNG26[i-1]+109, 256)
  15. RNG[i] = math.fmod(math.floor(math.fmod(RNG24[i],256)*RNG26[i]/16),256)
  16. bit = math.fmod(math.floor(math.fmod(RNG24[i],256)*RNG26[i]/4),4)
  17. end
  18.  
  19. function search_RNGpos()
  20. local cur24 = memory.readword(0x7E0024)
  21. local cur26 = memory.readbyte(0x7E0026)
  22. RNGpos = RNGoffset
  23. for i=RNGoffset, 256 do
  24. if(RNG26[i]==cur26) then
  25. for j=i, RNGend, 256 do
  26. if(RNG24[j]==cur24) then
  27. RNGpos = j
  28. break
  29. end
  30. end
  31. break
  32. end
  33. end
  34. end
  35.  
  36. function draw_RNGgraph(x,y,width,height)
  37. gui.box(x,y,x+width,y+height,"#FFFFFF50")
  38. gui.line(x+36,y+height+2,x+36,y-2,"#FFFFFF")
  39. gui.text(210,216,string.format("%5d/%5d",RNGpos,RNGend))
  40. gui.text(2,172,string.format("RNG: %3d",RNG[RNGpos]))
  41. for i=0,width do
  42. local color = "#00FF2080"
  43. local curRNG = RNG[(RNGpos+i)%14592]
  44. if curRNG==0 then
  45. color = "#FF1010FF" -- 1/128 Item Drop
  46. curRNG=256
  47. elseif curRNG==128 then
  48. color = "#FFFF30FF" -- 1/128 Item Drop
  49. elseif curRNG==255 then
  50. color = "#0080FFFF" -- MAX
  51. curRNG=256
  52. elseif curRNG<=12 then
  53. color = "#FF5050FF" -- SMAAAASH!!
  54. elseif curRNG>184 then
  55. color = "#0030FF90" -- No enemies
  56. end
  57. gui.line(x+i,y+height,x+i,y+height-math.floor(curRNG/256*height),color)
  58. end
  59. end
  60.  
  61.  
  62. function watch_pos()
  63. local x,y = 150,146
  64. local xadr = 0x7E9B26 -- MOTHER 2
  65. -- local xadr = 0x7E9875 -- EARTH BOUND
  66. gui.text(x,y,
  67. string.format("X-Pos: %5d \n",memory.readword(xadr+2))..
  68. string.format("X-Sub: %5d \n",memory.readword(xadr-0))..
  69. string.format("Y-Pos: %5d \n",memory.readword(xadr+6))..
  70. string.format("Y-Sub: %5d \n",memory.readword(xadr+4))
  71. )
  72.  
  73. color = "#00ff80"
  74. gui.text(208, 146, "No use", color)
  75. color = "#FF5050FF"
  76. gui.text(208, 154, "SMAAAASH!!", color)
  77. color = "#0080FFFF"
  78. gui.text(208, 162, "No enemies", color)
  79. color = "#FFFF30FF"
  80. gui.text(208, 170, "1/128 Item", color)
  81.  
  82. m = memory.readwordsigned(0x7E9AE2)
  83. gui.text(2,144,"Money: "..m)
  84. atm = memory.readwordsigned(0x7E9AE6)
  85. gui.text(2,151,"ATM: "..atm)
  86. ss = memory.readwordsigned(0x7E9AE6)
  87. gui.text(2,158,"Skip S.: "..ss)
  88. dr = memory.readwordsigned(0x7EABE5)
  89. gui.text(2,165,"Drop : "..dr)
  90. gui.text(66,163,"EnemyHP: "..memory.readword(0x7EA431), color)
  91. gui.text(66,170,"Ness HP: "..memory.readword(0x7E9CC5), color)
  92. gui.text(2,216,emu.framecount())
  93. end
  94.  
  95. emu.registerbefore(search_RNGpos)
  96.  
  97. gui.register(function()
  98. draw_RNGgraph(0,182,255,32)
  99. watch_pos()
  100. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement