Kirkq

Magical Popn Bizhawk Lua

Jun 10th, 2017
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.03 KB | None | 0 0
  1. local CharID = 0x7E1000
  2. local OnGround = 0x7E1002  -- 8 on ground, not 8 in air
  3. local XPos = 0x7E1004
  4. local XSubpixel = 0x7E1006
  5. local XVelocity = 0x7E100C
  6. local YPos = 0x7E1008
  7. local YSubpixel = 0x7E100A
  8. local YVelocity = 0x7E100E
  9. local JumpAd = 0x7E0056
  10.  
  11. local Health = 0x7E051A
  12.  
  13.  
  14.  
  15. local XVel
  16. local YVel
  17. local LastXPos = 0
  18. local CurrXPos = 0
  19. local LastXSub = 0
  20. local CurrXSub = 0
  21. local LastYPos = 0
  22. local CurrYPos = 0
  23. local LastYSub = 0
  24. local CurrYSub = 0
  25.  
  26. local BossY = 0x7E0C02  --7E0C02, 7E0C12, 7E1098
  27. local BossAction = 0x7E10A0
  28. local BossHealth = 0x7E051C
  29.  
  30. local RealXVel = {}
  31. --Note that a knockback speed of 15 just holds the previous speed for a frame
  32. RealXVel[0]= 0
  33. RealXVel[14] = 3.4375
  34. RealXVel[13] = 3.3633
  35. RealXVel[12] = 3.2930
  36. RealXVel[11] = 3.1094
  37. RealXVel[10]= 3.035
  38. RealXVel[9]= 2.9258
  39. RealXVel[8]= 2.8164
  40. RealXVel[7]= 2.75
  41. RealXVel[6]= 2.3047
  42. RealXVel[5]= 2.0117
  43. RealXVel[4]= 1.535
  44. RealXVel[3]= 1.0625
  45. RealXVel[2]= 1
  46. RealXVel[1]= 1
  47. RealXVel[-14] = -3.4375
  48. RealXVel[-13] = -3.3633
  49. RealXVel[-12] = -3.2930
  50. RealXVel[-11] = -3.109
  51. RealXVel[-10]= -3.035
  52. RealXVel[-9]= -2.9258
  53. RealXVel[-8]= -2.8164
  54. RealXVel[-7]= -2.75
  55. RealXVel[-6]= -2.3047
  56. RealXVel[-5]= -2.0117
  57. RealXVel[-4]= -1.535
  58. RealXVel[-3]= -1.0625
  59. RealXVel[-2]= -2
  60. RealXVel[-1]= -2
  61.  
  62. local RealYVel = {}
  63.  
  64. RealYVel[-28] = -8.3633
  65. RealYVel[-27] = -8.3633
  66. RealYVel[-26] = -8.2773
  67. RealYVel[-25] = -8.1054
  68. RealYVel[-24] = -8.0195
  69. RealYVel[-23] = -7.8516
  70. RealYVel[-22] = -7.6797
  71. RealYVel[-21] = -7.5078
  72. RealYVel[-20] = -7.2539
  73. RealYVel[-19] = -7.0820
  74. RealYVel[-18] = -6.8281
  75. RealYVel[-17] = -6.5703
  76. RealYVel[-16] = -6.3164
  77. RealYVel[-15] = -5.9726
  78. RealYVel[-14] = -5.7187
  79. RealYVel[-13] = -5.3750
  80. RealYVel[-12] = -5.0351
  81. RealYVel[-11] = -4.6914
  82. RealYVel[-10] = -4.3516
  83. RealYVel[-9] = -4.0117
  84. RealYVel[-8] = -3.5859
  85. RealYVel[-7] = -3.2422
  86. RealYVel[-6] = -2.8164
  87. RealYVel[-5] = -2.4766
  88. RealYVel[-4] = -2.0469
  89. RealYVel[-3] = -1.6211
  90. RealYVel[-2] = -1.1953
  91. RealYVel[-1] = -0.7695
  92. RealYVel[0] = -0.3398
  93. RealYVel[1] = 2.0469
  94. RealYVel[2] = 2.4766
  95. RealYVel[3] = 2.0469
  96. RealYVel[4] = 2.4766
  97. RealYVel[5] = 2.8164
  98. RealYVel[6] = 3.2422
  99. RealYVel[7] = 3.5859
  100. RealYVel[8] = 4.0117
  101. RealYVel[9] = 4.3516
  102. RealYVel[10] = 4.6914
  103. RealYVel[11] = 5.0352
  104. RealYVel[12] = 5.3750
  105. RealYVel[13] = 5.7187
  106. RealYVel[14] = 5.9727
  107. RealYVel[15] = 6.3164
  108. RealYVel[16] = 6.5703
  109. RealYVel[17] = 6.8281
  110. RealYVel[18] = 7.0820
  111. RealYVel[19] = 7.2539
  112. RealYVel[20] = 7.5078
  113. RealYVel[21] = 7.6797
  114. RealYVel[22] = 7.8516
  115. RealYVel[23] = 8.0195
  116. RealYVel[24] = 8.1055
  117. RealYVel[25] = 8.2773
  118. RealYVel[26] = 8.3633
  119. RealYVel[27] = 8.3633
  120. RealYVel[28] = 8.4492
  121. RealYVel[29] = 8.4492
  122. RealYVel[30] = 8.5351
  123. RealYVel[31] = 9.4414
  124. RealYVel[32] = 10.078
  125. RealYVel[33] = 10.719
  126. RealYVel[34] = 11.199
  127. RealYVel[35] = 11.840
  128. RealYVel[36] = 12.320
  129. RealYVel[37] = 12.801
  130. RealYVel[38] = 13.281
  131. RealYVel[39] = 13.602
  132. RealYVel[40] = 14.078
  133. RealYVel[41] = 14.398
  134. RealYVel[42] = 14.719
  135. --anything over 42 is 14.719
  136.  
  137. local Offset
  138. local Flag
  139. local Count
  140.  
  141. local CurrBossY
  142. local MaxBossY = 100
  143.  
  144. while true do
  145.  
  146. --memory.writebyte(Health,6)
  147. --CurrBossY = memory.read_u16_le(BossY)
  148. --CurrAction = memory.readbyte(BossAction)
  149. --if CurrBossY > MaxBossY and CurrAction ~= 11 and CurrAction ~= 12 and CurrAction ~= 13 and CurrBossY < 1000 then
  150. --MaxBossY = CurrBossY
  151. --end
  152.  
  153. --gui.text(200,100,"Curr: " .. memory.read_u16_le(BossY))
  154. --gui.text(200,115,"Max: " .. MaxBossY) --523
  155. --gui.text(200,130,"BHealth: " .. memory.read_u16_le(BossHealth))
  156.  
  157.  
  158. Offset = 0x0
  159. Flag = 0
  160. Count = 0
  161. while Flag~=1 do
  162.     if memory.read_u16_le(CharID + Offset) ~= 40713 then
  163.     Offset = Offset + 0x30
  164.     Count = Count + 1
  165.     else
  166.     Flag = 1
  167.     end
  168.     if Count > 30 then
  169.     Flag = 1
  170.     gui.text(60,85,"SEARCHING")
  171.     end
  172. end
  173.  
  174.  
  175. XVel = memory.readbyte(XVelocity + Offset)
  176. if XVel > 200 then
  177. XVel = XVel - 256
  178. end
  179. YVel = memory.readbyte(YVelocity + Offset)
  180. if YVel > 200 then
  181. YVel = YVel - 256
  182. end
  183.  
  184. LastXPos = CurrXPos
  185. CurrXPos = memory.read_u16_le(XPos + Offset)
  186. LastXSub = CurrXSub
  187. CurrXSub = memory.read_u16_le(XSubpixel + Offset)/65535
  188. LastYPos = CurrYPos
  189. CurrYPos = memory.read_u16_le(YPos + Offset)
  190. LastYSub = CurrYSub
  191. CurrYSub = memory.read_u16_le(YSubpixel + Offset)/65535
  192.  
  193. gui.text(35,0,"XVel: " .. XVel)
  194. gui.text(35,40,"YVel: " .. YVel)
  195.  
  196. InterpX = CurrXPos + CurrXSub - LastXPos - LastXSub
  197. InterpY = CurrYPos + CurrYSub - LastYPos - LastYSub
  198.  
  199. if InterpX > -0.001 and InterpX < 0.001 then
  200. InterpX = 0
  201. end
  202. if InterpY> -0.001 and InterpY < 0.001 then
  203. InterpY = 0
  204. end
  205.  
  206.     if XVel <= 14 and XVel >= -14 then
  207.     gui.text(240,0,"RealVel: " .. RealXVel[XVel])
  208.     else
  209.     gui.text(240,0,"InterpVel: " .. InterpX)
  210.     end
  211.    
  212.     if YVel >= -28 then
  213.         if YVel > 42 then
  214.         YVel = 42
  215.         end
  216.         if YVel ~= 0 or (YVel == 0 and memory.readbyte(OnGround + Offset) ~=8) then
  217.         gui.text(240,40,"RealVel: " .. RealYVel[YVel])
  218.         else
  219.         gui.text(240,40,"RealVel: 0")
  220.         end
  221.     else
  222.     gui.text(240,40,"InterpVel: " .. InterpY)
  223.     end
  224.  
  225. if XVel <= 14 and XVel >= -14 then
  226.     if math.abs(InterpX - RealXVel[XVel]) > 0.05 then
  227.     gui.text(550,0,"?")
  228.     end
  229. end
  230. if YVel >= -17 and YVel ~= 0 then
  231.     if math.abs(InterpY - RealYVel[YVel]) > 0.05 then
  232.     gui.text(550,40,"?")
  233.     end
  234. end
  235. if YVel == 0 then
  236.     --On ground
  237.     if memory.readbyte(OnGround + Offset) == 8 then
  238.         if math.abs(InterpY - 0) > 0.05 then
  239.         gui.text(550,40,"?")
  240.         end
  241.     -- In air
  242.     elseif math.abs(InterpY - RealYVel[YVel]) > 0.05 then
  243.     gui.text(550,40,"?")
  244.     end
  245. end
  246.  
  247. gui.text(240,15,"InterpVel: " .. InterpX)
  248. gui.text(240,55,"InterpVel: " .. InterpY)
  249.  
  250.  
  251.  
  252. gui.text(35,15,"Xpos: " .. CurrXPos)
  253. gui.text(35,55,"Ypos: " .. CurrYPos)
  254.  
  255. if CurrXSub*100 < 10 and CurrXSub*100 > 0 then
  256. gui.text(135,15," . 0")
  257. gui.text(175,15,math.floor(CurrXSub*100))
  258. else
  259. gui.text(135,15," . " .. math.floor(CurrXSub*100))
  260. end
  261.  
  262. if CurrYSub*100 < 10 and CurrYSub*100 > 0 then
  263. gui.text(135,55," . 0")
  264. gui.text(175,55,math.floor(CurrYSub*100))
  265. else
  266. gui.text(135,55," . " .. math.floor(CurrYSub*100))
  267. end
  268.  
  269. gui.text(240,70,"Jump: " .. memory.readbyte(JumpAd))
  270.  
  271. emu.frameadvance();
  272. end
Advertisement
Add Comment
Please, Sign In to add comment