Kirkq

Quest 64 Lua V16

Nov 25th, 2018
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.22 KB | None | 0 0
  1. function round(num, numDecimalPlaces)
  2. local mult = 10^(numDecimalPlaces or 0)
  3. return math.floor(num * mult + 0.5) / mult
  4. end
  5.  
  6. function printMemoryDomains(x,y)
  7. local list = {}
  8. list = memory.getmemorydomainlist()
  9. local curr = memory.getcurrentmemorydomain()
  10. local num = table.getn(list)
  11. local i
  12. gui.text(x,y,"Current: " .. curr)
  13. for i=0,num do
  14. gui.text(x,y + 15*(i+1),list[i])
  15. end
  16. end
  17.  
  18. function printLocation(x,y)
  19. --0x7BABC related to movement startup
  20. XSpeed = memory.readfloat(0x7BAE4, true, "RDRAM")
  21. YSpeed = memory.readfloat(0x7BAEC, true, "RDRAM")
  22. YCamera = memory.readfloat(0x86E88, true, "RDRAM")
  23. XCamera = memory.readfloat(0x86E90, true, "RDRAM")
  24. XPos = memory.readfloat(0x7BACC, true, "RDRAM")
  25. YPos = memory.readfloat(0x7BAD4, true, "RDRAM")
  26. Speed = math.sqrt(XSpeed * XSpeed + YSpeed * YSpeed)
  27. gui.text(x,y + 0,"X: " .. round(XPos,24))
  28. gui.text(x,y+15,"Y: " .. round(YPos,24))
  29. gui.text(x,y+30,"XSpeed: " .. round(XSpeed,4))
  30. gui.text(x,y+45,"YSpeed: " .. round(YSpeed,4))
  31. gui.text(x,y+60,"Speed: " .. round(Speed,4))
  32. gui.text(x,y+75,"XCam: " .. round(XCamera,4)) -- Negative 1 is +X when holding up.
  33. gui.text(x,y+90,"YCam: " .. round(YCamera,4)) -- Negative 1 is +Y when holding up. -- (-128 to +127)
  34. CamAngle = math.atan2(YCamera,XCamera)
  35. ArbitraryX = 28
  36. ArbitraryY = 617
  37. YDiff = YPos - ArbitraryY
  38. XDiff = XPos - ArbitraryX
  39. AngleToDest = math.atan2(YDiff,XDiff)
  40. AngleToHold = (CamAngle - AngleToDest) + (math.pi/2)
  41. gui.text(x,y+105,"CamAngle (rad): " .. round(CamAngle,4))
  42. gui.text(x,y+120,"Angle to Dest (rad): " .. round(AngleToDest,4))
  43. gui.text(x,y+135,"Angle to Hold (rad): " .. round(AngleToHold,4)) -- Add or subtract pi/2 as needed
  44. gui.text(x,y+150,"DistFromDest: " .. round(math.sqrt(XDiff * XDiff + YDiff * YDiff),4))
  45. gui.text(x,y+165,"JoyStickTotal: " .. JoystickTotal)
  46.  
  47. ANGLE=0
  48. XHOLD=1
  49. YHOLD=2
  50. -- THIS IS CURRENTLY ONLY AN APPROXIMATION
  51. for i=0,1019 do
  52. if (math.abs(JoystickTable[i][ANGLE] - AngleToHold)) < 0.02 then
  53. gui.text(x,y+180,"Move " .. JoystickTable[i][XHOLD] .. " " .. JoystickTable[i][YHOLD])
  54. i= 9999
  55. break
  56. end
  57. end
  58. --There's a slight deadzone near the cardinal angles. -7 to +7 = 0
  59. end
  60. --84EE6 and 84EEE strongly related to "area/zone or maybe music"
  61. --memory.write_u16_be(0x084EE6, 2, "RDRAM")
  62. --memory.write_u16_be(0x084EEE, 2, "RDRAM")
  63. --memory.write_u16_be(0x08536A, 2, "RDRAM")
  64.  
  65. function calculateJoystickTableAngle()
  66. index=0
  67. ANGLE=0
  68. XHOLD=1
  69. YHOLD=2
  70.  
  71. JoystickTable = {}
  72. for i=0,1020 do
  73. JoystickTable[i]={}
  74. end
  75.  
  76. x=127
  77. for y=0,127 do
  78. JoystickTable[index][ANGLE] = math.atan2(y,x)
  79. JoystickTable[index][XHOLD] = x
  80. JoystickTable[index][YHOLD] = y
  81. index=index+1
  82. end
  83. y=127
  84. for x=126,-128,-1 do
  85. JoystickTable[index][ANGLE] = math.atan2(y,x)
  86. JoystickTable[index][XHOLD] = x
  87. JoystickTable[index][YHOLD] = y
  88. index=index+1
  89. end
  90. x=-128
  91. for y=126,-128,-1 do
  92. JoystickTable[index][ANGLE] = math.atan2(y,x)
  93. JoystickTable[index][XHOLD] = x
  94. JoystickTable[index][YHOLD] = y
  95. index=index+1
  96. end
  97. y=-128
  98. for x=-127,127 do
  99. JoystickTable[index][ANGLE] = math.atan2(y,x)
  100. JoystickTable[index][XHOLD] = x
  101. JoystickTable[index][YHOLD] = y
  102. index=index+1
  103. end
  104. x=127
  105. for y=-127,-1 do
  106. JoystickTable[index][ANGLE] = math.atan2(y,x)
  107. JoystickTable[index][XHOLD] = x
  108. JoystickTable[index][YHOLD] = y
  109. index=index+1
  110. end
  111. JoystickTotal=index
  112. --If you want to interleave intermediate angles, do a sort, but need to make sure things aren't equal.
  113. end
  114.  
  115. function printItems(x,y)
  116. for i=1,30 do
  117. Item = memory.readbyte(0x8CF78 + (i -1), "RDRAM")
  118. if Item ~= 255 and Item <= 25 then
  119. gui.text(x,y + 15*(i-1), "Item:" .. globalItemList[Item+1])
  120. end
  121. end
  122. end
  123.  
  124. function printAgility (x,y)
  125. --gui.text(x,y + 15*0,"Agi(?): " .. round(memory.readfloat(0x7BC14, true, "RDRAM"),4))
  126. --gui.text(x+200,y + 15*0,"/800")
  127. gui.text(x,y + 15*1,"AgiField: " .. round(memory.readfloat(0x7BC18, true, "RDRAM"),4))
  128. gui.text(x+200,y + 15*1,"/1000")
  129. gui.text(x,y+15*2,"AgiTown: " .. round(memory.readfloat(0x7BC1C, true, "RDRAM"),4))
  130. gui.text(x+200,y + 15*2,"/2000")
  131. gui.text(x,y+15*3,"AgiBattle:" .. round(memory.readfloat(0x7BCA0, true, "RDRAM"),4))
  132. gui.text(x+200,y + 15*3,"/50")
  133. gui.text(x,y+15*4,"MPRecharge: " .. round(memory.readfloat(0x7BC0C, true, "RDRAM"),4))
  134. gui.text(x+200,y + 15*4,"/35")
  135.  
  136. --gui.text(x,y+15*3,"Camera: " .. round(memory.readfloat(0x85D3C, true, "RDRAM"),4))
  137. --gui.text(x,y+15*4,"Camera: " .. round(memory.readfloat(0x85DAC, true, "RDRAM"),4))
  138. --gui.text(x,y+15*5,"Camera: " .. round(memory.readfloat(0x85DE4, true, "RDRAM"),4))
  139. --gui.text(x,y+15*6,"Camera: " .. round(memory.readfloat(0x85E54, true, "RDRAM"),4))
  140. gui.text(x,y+15*7,"BattleLastX: " .. round(memory.readfloat(0x86B18, true, "RDRAM"),4))
  141. --gui.text(x,y+15*8,"BattleLastZ: " .. round(memory.readfloat(0x86B1C, true, "RDRAM"),4))
  142. gui.text(x,y+15*8,"BattleLastY: " .. round(memory.readfloat(0x86B20, true, "RDRAM"),4))
  143. gui.text(x,y+15*9,"CameraCenteredHereX: " .. round(memory.readfloat(0x86DD8, true, "RDRAM"),4))
  144. --gui.text(x,y+15*9,"CameraCenteredHereZ: " .. round(memory.readfloat(0x86DDC, true, "RDRAM"),4))
  145. gui.text(x,y+15*10,"CameraCenteredHereY: " .. round(memory.readfloat(0x86DE0, true, "RDRAM"),4))
  146. --gui.text(x,y+15*9,"ArenaX: " .. round(memory.readfloat(0x88188, true, "RDRAM"),4))
  147. --gui.text(x,y+15*10,"ArenaX: " .. round(memory.readfloat(0x881B8, true, "RDRAM"),4))
  148. --gui.text(x,y+15*11,"ArenaX: " .. round(memory.readfloat(0x8C5A4, true, "RDRAM"),4))
  149. end
  150.  
  151. function printEncounterCounter(x,y)
  152. gui.text(x,y,"EncCount: " .. memory.read_u16_be(0x8C578, "RDRAM"))
  153. --You can cheese 1.9 pixels as it rolls over.
  154. gui.text(x+190,y,"/2000")
  155. gui.text(x,y + 15,"Increment: " .. round(memory.readfloat(0x8C574, true, "RDRAM"),4))
  156.  
  157. if encZState == 0 then
  158. gui.text(x,y + 30,"EncMode(Z): Normal")
  159. elseif encZState == 1 then
  160. gui.text(x,y + 30,"EncMode(Z): Max")
  161. elseif encZState == 2 then
  162. gui.text(x,y + 30,"EncMode(Z): None")
  163. gui.text(x,y + 45,"Count: " .. encAggregate)
  164. end
  165.  
  166. RNG_EC = memory.read_u32_be(0x4D748, "RDRAM")
  167. gui.text(x,y + 60, "RNG: " .. RNG_EC .. " = " .. string.format("%08X ", RNG_EC))
  168. gui.text(x,y + 75, "A: " .. memory.read_u16_be(0x22FE2, "RDRAM"))
  169. gui.text(x,y + 90, "B: " .. memory.read_u16_be(0x22FE4, "RDRAM") - 1000)
  170. gui.text(x,y + 105, "C: " .. memory.read_u16_be(0x22FE6, "RDRAM"))
  171. end
  172.  
  173. function maxEncounterCounter()
  174. memory.write_u16_be(0x8C578, 2000, "RDRAM")
  175. memory.writefloat(0x8C574, 49.98, true, "RDRAM")
  176. end
  177.  
  178. function freezeEncounterCounter()
  179. memory.write_u16_be(0x8C578, 0, "RDRAM")
  180. memory.writefloat(0x8C574, 0, true, "RDRAM")
  181. end
  182.  
  183. function highEncounterCounter()
  184. memory.write_u16_be(0x8C578, 1800,"RDRAM")
  185. end
  186.  
  187. function toggleEncounterCounterWithZ()
  188. local keyTable = joypad.get(1)
  189. if keyTable.Z == true then
  190. if zLockout == 0 then
  191. zLockout = 1
  192. encZState = encZState + 1
  193. if encZState == 2 then
  194. freezeEncounterCounter()
  195. encAggregate = 0
  196. end
  197. if encZState > 2 then
  198. encZState = 0
  199. end
  200. end
  201. else
  202. zLockout = 0
  203. end
  204.  
  205. if encZState == 1 then
  206. maxEncounterCounter()
  207. elseif encZState == 2 then
  208. encCurrVal = round(memory.readfloat(0x8C574, true, "RDRAM"),4)
  209. if encCurrVal > 0.001 then
  210. encAggregate = encAggregate + encCurrVal
  211. memory.writefloat(0x8C574, 0, true, "RDRAM")
  212. end
  213. end
  214. end
  215.  
  216. function printEnemyStats(x,y)
  217. EnemiesLeft = memory.readbyte(0x07C993, "RDRAM")
  218. TimeUntilYouAct = memory.read_u16_be(0x07C99A, "RDRAM")
  219.  
  220. gui.text(x,y,"ToAct:" .. TimeUntilYouAct)
  221.  
  222. NumEnemies = EnemiesLeft -- For Now, Not Ideal
  223. if NumEnemies > 0 then
  224. for i=1,NumEnemies do
  225. Base = 0x07C99C --next = 0x07CAC4
  226. WalkDec1 = memory.read_u16_be(0x07C99C + 296*(i-1), "RDRAM")
  227. RelatedToAttacking = memory.read_u16_be(0x07C99E + 296*(i-1), "RDRAM")
  228. RelatedToAttacking2 = memory.read_u16_be(0x07C9A0 + 296*(i-1), "RDRAM")
  229. FloatSomething = memory.readfloat(0x7C9A8 + 296*(i-1), true, "RDRAM")
  230. CurrHP = memory.read_u16_be(0x07C9A2 + 296*(i-1), "RDRAM") --9A2 and ACA and BF2 --7C993 = dead? 3 = alive, 2 = dead? (296 = 0x128)
  231. MaxHP = memory.read_u16_be(0x07C9A4 + 296*(i-1), "RDRAM")
  232. X = memory.readfloat(0x7C9BC + 296*(i-1), true, "RDRAM")
  233. Z = memory.readfloat(0x7C9C0 + 296*(i-1), true, "RDRAM")
  234. Y = memory.readfloat(0x7C9C4 + 296*(i-1), true, "RDRAM")
  235.  
  236. RapidlyChanging1 = memory.read_u16_be(0x07C9C6 + 296*(i-1), "RDRAM")
  237. RapidlyChanging2 = memory.read_u16_be(0x07C9D4 + 296*(i-1), "RDRAM")
  238. RapidlyChanging3 = memory.read_u16_be(0x07C9D6 + 296*(i-1), "RDRAM")
  239. RapidlyChanging4 = memory.read_u16_be(0x07C9DC + 296*(i-1), "RDRAM")
  240. RapidlyChanging5 = memory.read_u16_be(0x07C9DE + 296*(i-1), "RDRAM")
  241.  
  242. SizeModifier = memory.readfloat(0x7C9E0 + 296*(i-1), true, "RDRAM")
  243. --memory.writefloat(0x7C9E0, 0.4, true, "RDRAM") -- Meme Address
  244. TrueSize = memory.readfloat(0x7C9E4 + 296*(i-1), true, "RDRAM")
  245. Float3 = memory.readfloat(0x7C9E8 + 296*(i-1), true, "RDRAM")
  246. Float4 = memory.readfloat(0x7C9EC + 296*(i-1), true, "RDRAM")
  247. Float5 = memory.readfloat(0x7C9F0 + 296*(i-1), true, "RDRAM")
  248.  
  249.  
  250. --Hell Hound: Anything below 20.9 distance from center to center."
  251. --Were Hare less than 15.6 hits. Difference of 5.3
  252.  
  253. --Hell Hound sphere of influence is about 27.0
  254. -- 0.084
  255. -- 130
  256. -- 130 * 0.084 = 10.92
  257. -- -1.428
  258. -- 1
  259. -- 120
  260.  
  261. -- 0.07
  262. -- 80
  263. -- 80 * 0.07 = 5.6
  264. -- 0.2275
  265. -- 1
  266. -- 120
  267.  
  268.  
  269. ID = memory.readbyte(0x07CA0D + 296*(i-1), "RDRAM") --A0D
  270.  
  271. RapidlyChanging6 = memory.read_u16_be(0x07CA10 + 296*(i-1), "RDRAM")
  272. RapidlyChanging7 = memory.read_u16_be(0x07CA12 + 296*(i-1), "RDRAM")
  273. RelatedToAttacking3 = memory.readbyte(0x07CA19+ 296*(i-1), "RDRAM")
  274. Dunno1 = memory.readbyte(0x07CA1B+ 296*(i-1), "RDRAM")
  275. Atk = memory.read_u16_be(0x07CAAC + 296*(i-1), "RDRAM")
  276. Agi = memory.read_u16_be(0x07CAAE + 296*(i-1), "RDRAM")
  277. Def= memory.read_u16_be(0x07CAB0 + 296*(i-1), "RDRAM")
  278. --Exp does not appear to be here. Total Exp for battle maybe?
  279.  
  280. gui.text(x+100*(i-1),y+15,"HP:" .. CurrHP .. "/" .. MaxHP)
  281. gui.text(x+100*(i-1),y+30,"At:" .. Atk)
  282. gui.text(x+100*(i-1),y+45,"De:" .. Def)
  283. gui.text(x+100*(i-1),y+60,"Ag:" .. Agi)
  284. gui.text(x+100*(i-1),y+75,"ID:" .. ID)
  285. gui.text(x+100*(i-1),y+90,"WalkDec:" .. WalkDec1)
  286. gui.text(x+100*(i-1),y+105,"Size:" .. round(SizeModifier*TrueSize,4))
  287. --gui.text(x+100*(i-1),y+120,"3:" .. Dunno3)
  288. end
  289. end
  290. end
  291.  
  292.  
  293. --Solvaring
  294. --Zelse
  295. --Nepty
  296. --Shilf
  297. --Fargo
  298. --Guilty
  299. --Beigis Stats in ROM at D87944
  300. --Mammon in ROM at D8797C --Offset is 0x38
  301. --*
  302. --*
  303. --6 areas and bosses
  304. --
  305. --0x112664 07D0BF 07D0AF 07D0AE 07D0AD 07D0AA 07D0A9
  306. --1 96 68 9 39 8 39
  307. --0 116 112 90 41 89 41
  308. --255 136 184 144 38 144 38
  309. --0 156 164 32 40 31 40
  310. --0 176 192 140 39 140 39
  311.  
  312. --39 39 39 39 39 8 144 39 9 68 96 65 141
  313. --41 41 41 41 41 89 144 41 90 112 116 129 147
  314.  
  315. --Were Hare ADC094 80, 140, 0.07
  316. --Hell Hound 130, 170, 0.084
  317. --Man Eater 115, 135, 0.084
  318. --Big Mouth ADC13C 130, 70, 0.105
  319. --Parassault 90, 150, 0.077
  320. --Orc Jr 90, 150, 0.077
  321. --Gremlin 90, 140, 0.084
  322. --Skeleton 90, 135, 0.084
  323. --Ghost Hound 90, 238, 0.084
  324. --Merrow 130, 170, 0.084
  325. --Wolf Goat 80, 125, 0.084, 130, 170, 0.091
  326. --*
  327. --Goblin B6337C
  328. --Frog King
  329. --Apophis
  330. --Mad Doll
  331. --Death Hugger
  332. --Kobold
  333. --Man Trap
  334. --Bat
  335. --Frog Knight
  336. --Marionasty
  337. --Dark Goblin
  338. --Hot Lips
  339. --Ghost Stalker B6361C
  340. --Treant
  341. --Cockatrice
  342. --*
  343. --Multi-Optics BBDE9C
  344. --Mimic
  345. --Crawler
  346. --Scorpion
  347. --Scare Crow
  348. --Wyvern
  349. --Skelebat
  350. --Cryshell BBE024
  351. --Blood Jell
  352. --Caterpillar (9) -- C7D935 is interesting, may be red herring
  353. --Fish Man
  354. --*
  355. --Sandman (ID 0) C317EC
  356. --Werecat
  357. --Nightmare
  358. --Blue Man
  359. --Winged Sunfish
  360. --Gloon Wing
  361. --Ogre (ID 6)
  362. --Rocky (ID 7)
  363. --Red Wyvern
  364. --FlamedMane
  365. --Magma Fish
  366. --RedRose (ID 11)
  367. --WhiteRoseKnight: C31A8C
  368. --*
  369. --Orc C9BE54
  370. --Ghost C9BE8C
  371. --Will o Wisp
  372. --Sprite
  373. --JackoLantern
  374. --Arachnoid
  375. --Lamia
  376. --Temptress
  377. --Pixie
  378. --Grangach
  379. --Thunder Jell
  380. --Termant
  381. --*
  382. --Judgment HP: CC443C
  383. --Pin Head HP: CC44AC
  384. --Pale Rider: CC4474
  385. --Spriggan: CC44E4
  386.  
  387. --RNG ROM
  388. --023BE2 =16838 and 023BE6 = 20077
  389. --41C64E6Dh + 3039h
  390. --12345 or 13345 ??
  391. --023BE4
  392.  
  393. --RNG RAM
  394. --022FE0
  395. --memory.write_u16_be(0x22FE2, 0, "RDRAM")
  396. --memory.write_u16_be(0x22FE4, 300, "RDRAM")
  397. --memory.write_u16_be(0x22FE6, 0, "RDRAM")
  398.  
  399. --Avalanche Y starts at 0x86F2C
  400.  
  401. function printStats(x,y)
  402. local Exp = memory.read_u32_be(0x07BA90, "RDRAM")
  403. local HPLv = memory.readbyte(0x07BAB0, "RDRAM")
  404. local MPLv = memory.readbyte(0x07BAB1, "RDRAM")
  405. local AgiLv = memory.readbyte(0x07BAB2, "RDRAM")
  406. local DefLv = memory.readbyte(0x07BAB3, "RDRAM")
  407. local Lv = memory.readbyte(0x07BAB4, "RDRAM")
  408. local CurrHP = memory.read_u16_be(0x7BA84, "RDRAM")
  409. local MaxHP = memory.read_u16_be(0x7BA86, "RDRAM")
  410. local HPSub = memory.readbyte(0x7BAA9, "RDRAM")
  411. local CurrMP = memory.read_u16_be(0x7BA88, "RDRAM")
  412. local MaxMP = memory.read_u16_be(0x7BA8A, "RDRAM")
  413. local MPSub = memory.readbyte(0x7BAAB, "RDRAM")
  414. local Def = memory.readbyte(0x7BA8F, "RDRAM")
  415. local DefSub = memory.readbyte(0x7BAAF, "RDRAM")
  416. local Agi = memory.readbyte(0x7BA8D, "RDRAM")
  417. local AgiSub = memory.readbyte(0x7BAAD, "RDRAM")
  418. gui.text(x,y+0,"HP: " .. CurrHP .. "/" .. MaxHP .. " (" .. HPSub .. "/" .. globalStatTable[HPLv+1] ..")")
  419. gui.text(x,y+15,"MP: " .. CurrMP .. "/" .. MaxMP .. " (" .. MPSub .. "/" .. 4*globalStatTable[MPLv+1] ..")")
  420. gui.text(x,y+30,"Def: " .. Def .. " (" .. DefSub .. "/" .. 2*globalStatTable[DefLv+1] ..")")
  421. gui.text(x,y+45,"Agi: " .. Agi .. " (" .. AgiSub .. "/" .. globalStatTable[AgiLv+1] ..")")
  422. gui.text(x,y+60,"Lv: " .. Lv .. " (" .. Exp .. "/" .. globalLvTable[Lv+1] .. ")")
  423. end
  424.  
  425. function HP50()
  426. memory.write_u16_be(0x7BA84, 50, "RDRAM")
  427. end
  428. function setSpirits(f,e,wa,wi)
  429. memory.writebyte(0x7BAA4, f, "RDRAM")
  430. memory.writebyte(0x7BAA5, e, "RDRAM")
  431. memory.writebyte(0x7BAA6, wa, "RDRAM")
  432. memory.writebyte(0x7BAA7, wi, "RDRAM")
  433. end
  434. function setStats(HP,MP,De,Ag)
  435. memory.write_u16_be(0x7BA86, HP, "RDRAM")
  436. memory.write_u16_be(0x7BA8A, MP, "RDRAM")
  437. memory.writebyte(0x7BA8F, De, "RDRAM")
  438. memory.writebyte(0x7BA8D, Ag, "RDRAM")
  439. end
  440. function stackOfJewelsAndWings()
  441. --Earth Orb opens Connor Fortress door.
  442. --Wind Jade opens door to access Blue Cave.
  443. --Water Jewel reopens ship.
  444. memory.writebyte(0x8CF78, 20, "RDRAM")
  445. memory.writebyte(0x8CF79, 21, "RDRAM")
  446. memory.writebyte(0x8CF7A, 22, "RDRAM")
  447. memory.writebyte(0x8CF7B, 14, "RDRAM")
  448. memory.writebyte(0x8CF7C, 15, "RDRAM")
  449. memory.writebyte(0x8CF7D, 16, "RDRAM")
  450. memory.writebyte(0x8CF7E, 17, "RDRAM")
  451. memory.writebyte(0x8CF7F, 18, "RDRAM")
  452. memory.writebyte(0x8CF80, 19, "RDRAM")
  453. end
  454.  
  455. function setupLvTable(tmpTable)
  456. --This table is calculated off the current level.
  457. local i
  458. for i=1,99 do
  459. tmpTable[i] = memory.read_u32_be(0x05493C+4*(i-1),"ROM")
  460. end
  461. return tmpTable
  462. end
  463. function printLvTable(x,y,tmpTable)
  464. local i
  465. for i=1,99 do
  466. gui.text(x,y+i*15,tmpTable[i])
  467. end
  468. end
  469. function setupStatTable(tmpTable1)
  470. --This table is calculated off the concept of numStatLevels, not current level.
  471. local i
  472. for i=1,70 do
  473. tmpTable1[i] = memory.read_u16_be(0x054ACC+2*(i-1),"ROM")
  474. end
  475. return tmpTable1
  476. end
  477. function printStatTable(x,y,tmpTable1)
  478. --ROM 0x054909 is starting stats I think?
  479. local i
  480. for i=1,70 do
  481. gui.text(x,y+i*15,tmpTable1[i])
  482. end
  483. end
  484.  
  485. function printObjectCoordinates(x,y)
  486. --memory.writefloat(0x86F2C, 1600, true, "RDRAM")
  487. BrianX = memory.readfloat(0x7BACC, true, "RDRAM")
  488. BrianY = memory.readfloat(0x7BAD4, true, "RDRAM")
  489.  
  490. i = 1 --Enemy number 1 (starting at 1)
  491. EnemyX = memory.readfloat(0x7C9BC + 296*(i-1), true, "RDRAM")
  492. EnemyY = memory.readfloat(0x7C9C4 + 296*(i-1), true, "RDRAM")
  493.  
  494. for i=1,10 do
  495. --memory.writefloat(0x86F24 + 60*(i-1), -20, true, "RDRAM") --X
  496. --memory.writefloat(0x86F2C + 60*(i-1), -350, true, "RDRAM") --Y
  497.  
  498. --RightSide -1367,930
  499. --LeftSide -1327, 930
  500. --BackSide -1347, 948
  501. --FrontSide -1347, 908
  502.  
  503. --Hell Hound: Anything below 20.9 distance from center to center."
  504. --Were Hare less than 15.6 hits.
  505. --
  506. --Solvaring 10 + 8.4 Note: Solvaring is moving about half a pixel during standing.
  507. --Zelse 10 + 5.6 (Investigate Zelse Mid-Range) Zelse moves about 0.4 pixels during standing. He recoils a couple pixels when hit.
  508. --Nepty 10 + 4.9 Nepty moves about 0.4 px during standing.
  509. --Shilf 10 + 4.9 Shilf moves about 0.05
  510. --Fargo 10 + 7 moves about 0.05
  511. --Guilty 10 + 9.52 No movement
  512. --Beigis 10 + 6.3 No movement
  513. --Mammon 10 + 94.5 Moves around 0.6 px.
  514.  
  515. Timer = memory.read_u16_be(0x86F1C + 60*(i-1), "RDRAM")
  516. X = memory.readfloat(0x86F24 + 60*(i-1), true, "RDRAM")
  517. Z = memory.readfloat(0x86F28 + 60*(i-1), true, "RDRAM")
  518. Y = memory.readfloat(0x86F2C + 60*(i-1), true, "RDRAM")
  519. XDiff= BrianX - X
  520. YDiff= BrianY - Y
  521. D = math.sqrt(XDiff*XDiff + YDiff*YDiff)
  522. A = math.atan2(XDiff,YDiff)*(180/(math.pi))
  523. EnemyXDiff = EnemyX - X
  524. EnemyYDiff = EnemyY - Y
  525. EnemyD = math.sqrt(EnemyXDiff*EnemyXDiff + EnemyYDiff*EnemyYDiff)
  526. EnemyA = math.atan2(EnemyXDiff,EnemyYDiff)*(180/(math.pi))
  527.  
  528.  
  529.  
  530. j=0
  531. if i > 5 then
  532. j=1
  533. end
  534.  
  535. if (Timer > 0) then
  536. gui.text(x+140*(i-j*5-1),y+0*15 + j*100,"Timer: " .. Timer)
  537. gui.text(x+140*(i-j*5-1),y+1*15 + j*100,"X: " .. round(X,3))
  538. gui.text(x+140*(i-j*5-1),y+2*15 + j*100,"Z: " .. round(Z,3))
  539. gui.text(x+140*(i-j*5-1),y+3*15 + j*100,"Y: " .. round(Y,3))
  540. gui.text(x+140*(i-j*5-1),y+4*15 + j*100,"D: " .. round(D,3))
  541. gui.text(x+140*(i-j*5-1),y+5*15 + j*100,"A: " .. round(A,3)) --16 angles
  542. --gui.text(x+140*(i-j*5-1),y+4*15 + j*100,"D: " .. round(EnemyD,3))
  543. --gui.text(x+140*(i-j*5-1),y+5*15 + j*100,"A: " .. round(EnemyA,3))
  544. end
  545. end
  546.  
  547.  
  548. --F1C Timer
  549. --F24 X
  550. --F28 Z
  551. --F2C Y
  552.  
  553. --F60 X
  554. --F64 Z
  555. --F68 Y
  556. end
  557.  
  558. function rocksBrianToEnemy(BrianX1,BrianY1,EnemyX1,EnemyY1,Size1)
  559.  
  560. numRocks1 = 0
  561.  
  562. --textfile = "BizDump2"
  563. --dumpfile = textfile..".txt"
  564. --io.output(dumpfile)
  565.  
  566.  
  567. for i=0,15 do --Angles
  568. for j=20,39 do --Distances
  569. thisRockX1= BrianX1 + j*math.cos(i*22.5*math.pi/180)
  570. thisRockY1= BrianY1 + j*math.sin(i*22.5*math.pi/180)
  571.  
  572. XDiff1= thisRockX1 - EnemyX1
  573. YDiff1= thisRockY1 - EnemyY1
  574. D1 = math.sqrt(XDiff1*XDiff1 + YDiff1*YDiff1)
  575. if D1 <= Size1 + 10 then
  576. numRocks1 = numRocks1 + 1
  577. --io.write(thisRockX1, " ", thisRockY1, " ", i, " ", j, "\n")
  578. end
  579.  
  580. end
  581. end
  582.  
  583. --io.output():close()
  584.  
  585. return numRocks1
  586. end
  587.  
  588. function howManyRocksCurrently(x,y)
  589. BrianX = memory.readfloat(0x7BACC, true, "RDRAM")
  590. BrianY = memory.readfloat(0x7BAD4, true, "RDRAM")
  591. i = 1 --Enemy number 1 (starting at 1)
  592. EnemyX = memory.readfloat(0x7C9BC + 296*(i-1), true, "RDRAM")
  593. EnemyY = memory.readfloat(0x7C9C4 + 296*(i-1), true, "RDRAM")
  594. SizeModifier = memory.readfloat(0x7C9E0 + 296*(i-1), true, "RDRAM")
  595. TrueSize = memory.readfloat(0x7C9E4 + 296*(i-1), true, "RDRAM")
  596. Size = SizeModifier*TrueSize
  597. XDiff= BrianX - EnemyX
  598. YDiff= BrianY - EnemyY
  599. D = math.sqrt(XDiff*XDiff + YDiff*YDiff)
  600. A = math.atan2(XDiff,YDiff)*(180/(math.pi))
  601.  
  602. R = rocksBrianToEnemy(BrianX,BrianY,EnemyX,EnemyY,Size)
  603.  
  604. gui.text(x,y+15*0,"D: " .. round(D,3))
  605. gui.text(x,y+15*1,"A: " .. round(A,3))
  606. gui.text(x,y+15*2,"EnemySize:" .. round(Size,3))
  607. gui.text(x,y+15*3,"NumRocks:" .. R .. " (0x" .. string.format("%02X", R) .. ") ")
  608. gui.text(x,y+15*4,"BrianX:" .. BrianX)
  609. gui.text(x,y+15*5,"BrianY:" .. BrianY)
  610. gui.text(x,y+15*6,"EnemyX:" .. EnemyX)
  611. gui.text(x,y+15*7,"EnemyY:" .. EnemyY)
  612.  
  613. end
  614.  
  615. function heatMapGenerator()
  616. MapSize = 120
  617. BrianX = math.floor(MapSize/2)
  618. BrianY = math.floor(MapSize/2)
  619. Size = 6.3
  620. --Solvaring 10 + 8.4 Note: Solvaring is moving about half a pixel during standing.
  621. --Zelse 10 + 5.6 (Investigate Zelse Mid-Range) Zelse moves about 0.4 pixels during standing. He recoils a couple pixels when hit.
  622. --Nepty 10 + 4.9 Nepty moves about 0.4 px during standing.
  623. --Shilf 10 + 4.9 Shilf moves about 0.05
  624. --Fargo 10 + 7 moves about 0.05
  625. --Guilty 10 + 9.52 No movement
  626. --Beigis 10 + 6.3 No movement
  627. --Mammon 10 + 94.5 Moves around 0.6 px.
  628. heatTextfile = "HeatMap"
  629. heatDumpfile = heatTextfile..".txt"
  630. io.output(heatDumpfile)
  631.  
  632. Max = 0
  633.  
  634. for EnemyX=0,MapSize do
  635. for EnemyY=MapSize,0,-1 do
  636. R = rocksBrianToEnemy(BrianX,BrianY,EnemyX,EnemyY,Size)
  637. if R > Max then
  638. Max = R
  639. end
  640. io.write(string.format("%02X ", R))
  641. end
  642. io.write("\n")
  643. end
  644.  
  645. io.write("\n")
  646. io.write("EnemySize: " .. Size)
  647. io.write("\n")
  648. io.write("Max: ", string.format("%02X", Max))
  649. io.write("\n")
  650. io.write("MapSize: " .. MapSize+1)
  651.  
  652. io.output():close()
  653.  
  654.  
  655. end
  656.  
  657. globalItemList = {
  658. "0. Spirit Light",
  659. "1. Fresh Bread",
  660. "2. Honey Bread",
  661. "3. Healing Potion",
  662. "4 Dragon's Potion",
  663. "5. Dew Drop",
  664. "6. Mint Leaves",
  665. "7. Heroes Drink",
  666. "8. Silent Flute",
  667. "9.Celine's Bell",
  668. "10.Replica",
  669. "11.Giant's Shoes",
  670. "12.Silver Amulet",
  671. "13.Golden Amulet",
  672. "14.White Wings",
  673. "15.Yellow Wings",
  674. "16.Blue Wings",
  675. "17.Green Wings",
  676. "18.Red Wings",
  677. "19.Black Wings",
  678. "20.Earth Orb",
  679. "21.Wind Jade",
  680. "22.Water Jewel",
  681. "23.Fire Ruby",
  682. "24.Eletale Book",
  683. "25.Dark Gaol Key",
  684. }
  685.  
  686. function CalcNextRNG()
  687. RNG1 = memory.read_u32_be(0x04D748, "RDRAM")
  688. Next1RNG = getNextRNG(RNG1)
  689. Next2RNG = getNextRNG(Next1RNG)
  690. Next3RNG = getNextRNG(Next2RNG)
  691.  
  692. --gui.text(400,490,"NextLo: " .. string.format("%08X ",R_LO2))
  693. --gui.text(400,505,"NextHi: " .. string.format("%08X ",R_HI2))
  694. gui.text(400,520,"NextRNG1: " .. string.format("%08X ", Next1RNG))
  695. gui.text(400,535,"NextRNG2: " .. string.format("%08X ", Next2RNG))
  696. gui.text(400,550,"NextRNG3: " .. string.format("%08X ", Next3RNG))
  697. gui.text(400,565,"BufRNG1: " .. string.format("%08X ", BufRNG))
  698. gui.text(400,580,"BufRNG2: " .. string.format("%08X ", BufRNG2))
  699. gui.text(400,595,"BufRNG3: " .. string.format("%08X ", BufRNG3))
  700.  
  701. if RNGTableGlobal[1]~= nil then
  702. for i=1,100 do -- Was 10000
  703. if RNG1 == RNGTableGlobal[i] then
  704. gui.text(400,610,"RNG Increment: " .. i)
  705. i = 1000000
  706. end
  707. end
  708. end
  709.  
  710. modifier = 1
  711. if memory.read_u16_be(0x7BD30, "RDRAM")==1 then
  712. modifier = -1
  713. end
  714. Counter1 = modifier * memory.read_u16_be(0x7BD32, "RDRAM")
  715. if Counter1 ~= 1 then
  716. Last1 = Counter1
  717. end
  718. gui.text(400,625,"Counter1: " .. Counter1 .. " " .. Last1)
  719.  
  720. modifier = 1
  721. if memory.read_u16_be(0x7BDB4, "RDRAM")==1 then
  722. modifier = -1
  723. end
  724. Counter2 = modifier * memory.read_u16_be(0x7BDB6, "RDRAM")
  725. if Counter2 ~= 1 then
  726. Last2 = Counter2
  727. end
  728. gui.text(400,640,"Counter2: " .. Counter2 .. " " .. Last2)
  729.  
  730. --[[
  731. modifier = 1
  732. if memory.read_u16_be(0x7C1B6, "RDRAM")==1 then
  733. modifier = -1
  734. end
  735. Counter6 = modifier * memory.read_u16_be(0x7C1B8, "RDRAM")
  736. if Counter6 ~= 1 then
  737. Last6 = Counter6
  738. end
  739. gui.text(400,700,"Counter6: " .. Counter6 .. " " .. Last6)
  740. --]]
  741.  
  742. modifier = 1
  743. if memory.read_u16_be(0x7C1D4, "RDRAM")==1 then
  744. modifier = -1
  745. end
  746. Counter3 = modifier * memory.read_u16_be(0x7C1D6, "RDRAM")
  747. if Counter3 ~= 1 then
  748. Last3 = Counter3
  749. end
  750. gui.text(400,655,"Counter3: " .. Counter3 .. " " .. Last3)
  751.  
  752. modifier = 1
  753. if memory.read_u16_be(0x7C258, "RDRAM")==1 then
  754. modifier = -1
  755. end
  756. Counter4 = modifier * memory.read_u16_be(0x7C25A, "RDRAM")
  757. if Counter4 ~= 1 then
  758. Last4 = Counter4
  759. end
  760. gui.text(400,670,"Counter4: " .. Counter4 .. " " .. Last4)
  761.  
  762. modifier = 1
  763. if memory.read_u16_be(0x7C23C, "RDRAM")==1 then
  764. modifier = -1
  765. end
  766. Counter5 = modifier * memory.read_u16_be(0x7C23E, "RDRAM")
  767. if Counter5 ~= 1 then
  768. Last5 = Counter5
  769. end
  770. gui.text(400,685,"Counter5: " .. Counter5 .. " " .. Last5)
  771.  
  772. Incrementer = memory.read_u16_be(0x86A1A, "RDRAM")
  773. if Incrementer > 32768 then
  774. Incrementer = Incrementer - 65536
  775. end
  776. Incrementer = Incrementer - 6
  777. gui.text(400,715,"Increment4: " .. Incrementer) -- see also 7C1D4.
  778. Incrementer = memory.read_u16_be(0x86A32, "RDRAM")
  779. if Incrementer > 32768 then
  780. Incrementer = Incrementer - 65536
  781. end
  782. Incrementer = Incrementer - 6
  783. gui.text(400,730,"Increment4: " .. Incrementer) -- see also 7C1D4.
  784.  
  785. --memory.write_u16_be(0x86A1A, 3, "RDRAM")
  786. --memory.write_u16_be(0x86A32, 3, "RDRAM")
  787.  
  788. --memory.write_u16_be(0x22FE2, 0, "RDRAM") --41C6 --0 FREEZES RNG
  789. --memory.write_u16_be(0x22FE4, 2001, "RDRAM")
  790. --memory.write_u16_be(0x22FE6, 1, "RDRAM") --4E6D --0 FREEZES RNG
  791.  
  792. --memory.write_u32_be(0x4D748, 0x00000001, "RDRAM")
  793.  
  794. --memory.write_u16_be(0x86A1A, 0, "RDRAM")
  795. --memory.write_u16_be(0x7BDB6, 10, "RDRAM")
  796. --memory.write_u16_be(0x7C1D6, 10, "RDRAM")
  797.  
  798. if PrevRNG ~= Next1RNG then
  799. BufRNG3 = PrevRNG3
  800. BufRNG2 = PrevRNG2
  801. BufRNG = PrevRNG
  802. PrevRNG3 = Next3RNG -- This is poorly buffered and doesn't quite work right, basically just a sanity check.
  803. PrevRNG2 = Next2RNG -- This is poorly buffered and doesn't quite work right, basically just a sanity check.
  804. PrevRNG = Next1RNG --Lol double buffer
  805. end
  806. end
  807.  
  808. function getNextRNG(passedRNG)
  809. A1 = memory.read_u16_be(0x22FE2, "RDRAM")
  810. B1 = memory.read_u16_be(0x22FE4, "RDRAM") - 1000
  811. C1 = memory.read_u16_be(0x22FE6, "RDRAM")
  812.  
  813. R_HI1 = math.floor(passedRNG/0x10000)
  814. R_LO1 = passedRNG % 0x10000
  815.  
  816. R_HI2 = A1 * R_LO1 + (R_HI1 * C1)
  817. R_HI2 = R_HI2 % 65536
  818. R_LO2 = R_LO1 * C1 + B1 --16,16,16
  819. passedRNG = (65536*R_HI2+R_LO2) % 0x100000000
  820.  
  821. return passedRNG
  822. end
  823.  
  824. function generateRNGTable(makeDumpfile)
  825.  
  826. RNGTextfile = "RNGDump"
  827. RNGDumpfile = RNGTextfile..".txt"
  828. if makeDumpfile then
  829. io.output(RNGDumpfile)
  830. startRNGSeed = 2209236614
  831. ThisR = startRNGSeed
  832. io.write(ThisR)
  833. io.write("\n")
  834. for i=2,10000 do
  835. ThisR = getNextRNG(ThisR)
  836. io.write(ThisR)
  837. io.write("\n")
  838. end
  839. io.output():close()
  840. end
  841.  
  842. --Magic Barrier Test Section
  843. --[[
  844. NN = 39
  845. RNGTextfile2 = "RNGDumpNOrdered"
  846. RNGDumpfile2 = RNGTextfile2..".txt"
  847. if makeDumpfile then
  848. io.output(RNGDumpfile2)
  849. startRNGSeed = 1
  850. ThisR = startRNGSeed
  851. for j = 1,NN do
  852. ThisR = getNextRNG(ThisR)
  853. end
  854. AA = ThisR
  855. for j = 1,NN do
  856. ThisR = getNextRNG(ThisR)
  857. end
  858. BB = ThisR
  859.  
  860. if ((math.floor(AA)/65536) % 100) >= 90 and ((math.floor(BB)/65536) % 100) >= 90 then
  861. io.write("1")
  862. io.write("\n")
  863. elseif ((math.floor(AA)/65536) % 100) >= 90 then
  864. io.write("0")
  865. io.write("\n")
  866. end
  867.  
  868. --io.write(ThisR)
  869. --io.write("\n")
  870. for i=2,10000 do
  871. ThisR = i
  872. for j = 1,NN do
  873. ThisR = getNextRNG(ThisR)
  874. end
  875. AA = ThisR
  876. for j = 1,NN do
  877. ThisR = getNextRNG(ThisR)
  878. end
  879. BB = ThisR
  880.  
  881. if ((math.floor(AA)/65536) % 100) >= 90 and ((math.floor(BB)/65536) % 100) >= 90 then
  882. io.write("1")
  883. io.write("\n")
  884. elseif ((math.floor(AA)/65536) % 100) >= 90 then
  885. io.write("0")
  886. io.write("\n")
  887. end
  888.  
  889. --io.write(ThisR)
  890. --io.write("\n")
  891. end
  892. io.output():close()
  893. end
  894. ]]
  895. --End Magic Barrier Test Section
  896.  
  897.  
  898. --Make table
  899. startRNGSeed = 2209236614
  900. ThisR = startRNGSeed
  901. RNGTableGlobal[1] = ThisR
  902. for i=2,10000 do
  903. ThisR = getNextRNG(ThisR)
  904. RNGTableGlobal[i] = ThisR
  905. end
  906.  
  907. end
  908.  
  909. function avalancheBasher()
  910. -- Start with a file loaded ready to cast avalanche.
  911.  
  912. --=20*(W2/22.5)+(V2-20)+180
  913. savestate.saveslot(9)
  914. AvTextfile = "Avalanche Basher"
  915. AvDumpfile = AvTextfile..".txt"
  916. io.output(AvDumpfile)
  917. startRNGSeed = 2209236614
  918. ThisR = startRNGSeed
  919. D = 0
  920. A = 0
  921. for j=1,20000 do
  922. savestate.loadslot(9)
  923. memory.write_u32_be(0x04D748, j, "RDRAM") -- RNG
  924. emu.frameadvance()
  925. joypad.set({["A"]=true},1)
  926. memory.write_u32_be(0x04D748, j, "RDRAM") -- RNG
  927. emu.frameadvance()
  928. joypad.set({["A"]=true},1)
  929. for k=1,36 do
  930. emu.frameadvance()
  931. memory.write_u32_be(0x04D748, j, "RDRAM") -- RNG
  932. gui.text(100,100,"D: " .. round(D,3))
  933. gui.text(100,115,"A: " .. round(A,3)) --16 angles
  934. gui.text(100,130,"Iteration: " .. j) --16 angles
  935. end
  936.  
  937. BrianX = memory.readfloat(0x7BACC, true, "RDRAM")
  938. BrianY = memory.readfloat(0x7BAD4, true, "RDRAM")
  939.  
  940. i = 1 --Enemy number 1 (starting at 1)
  941. EnemyX = memory.readfloat(0x7C9BC + 296*(i-1), true, "RDRAM")
  942. EnemyY = memory.readfloat(0x7C9C4 + 296*(i-1), true, "RDRAM")
  943. Timer = memory.read_u16_be(0x86F1C + 60*(i-1), "RDRAM")
  944. X = memory.readfloat(0x86F24 + 60*(i-1), true, "RDRAM")
  945. Z = memory.readfloat(0x86F28 + 60*(i-1), true, "RDRAM")
  946. Y = memory.readfloat(0x86F2C + 60*(i-1), true, "RDRAM")
  947. XDiff= BrianX - X
  948. YDiff= BrianY - Y
  949. D = math.sqrt(XDiff*XDiff + YDiff*YDiff)
  950. D = round(D,3)
  951. A = math.atan2(XDiff,YDiff)*(180/(math.pi))
  952. A = round(A,3)
  953. EnemyXDiff = EnemyX - X
  954. EnemyYDiff = EnemyY - Y
  955. EnemyD = math.sqrt(EnemyXDiff*EnemyXDiff + EnemyYDiff*EnemyYDiff)
  956. EnemyA = math.atan2(EnemyXDiff,EnemyYDiff)*(180/(math.pi))
  957.  
  958. ThisR = getNextRNG(ThisR)
  959. --=20*(W4/22.5)+(V4-20)+180
  960. V = 20 * (A/22.5)+(D-20) + 180 --unique Rock ID
  961.  
  962. io.write(V)
  963. io.write("\n")
  964. end
  965. io.output():close()
  966.  
  967. end
  968.  
  969. function encounterRateBasher()
  970. -- Start with a file loaded ready to hold up to get into a battle within a couple frames.
  971. -- You also need to be away from RNG incrementation on the overworld for good results.
  972.  
  973. --=20*(W2/22.5)+(V2-20)+180
  974. savestate.saveslot(9)
  975. startEnc = 0
  976.  
  977. -- 50 times 40 is 2000
  978. for k=0,40 do
  979. EnTextfile = "Encounter Basher New"
  980. EnTextfile = EnTextfile..startEnc
  981. EnDumpfile = EnTextfile..".txt"
  982. io.output(EnDumpfile)
  983. startRNGSeed = 2209236614
  984. ThisR = startRNGSeed
  985.  
  986.  
  987.  
  988. for j=1,100 do
  989. savestate.loadslot(9)
  990. -- Set Enc Counter to value
  991. memory.write_u16_be(0x8C578, startEnc, "RDRAM") -- Encounter Rate increment
  992. memory.write_u32_be(0x04D748, ThisR, "RDRAM") -- RNG
  993. emu.frameadvance()
  994. joypad.set({["A Up"]=true},1)
  995. gui.text(100,130,"Iteration: " .. k .. " " .. j) --16 angles
  996. emu.frameadvance()
  997. joypad.set({["A Up"]=true},1)
  998. gui.text(100,130,"Iteration: " .. k .. " " .. j) --16 angles
  999. emu.frameadvance()
  1000. joypad.set({["A Up"]=true},1)
  1001. gui.text(100,130,"Iteration: " .. k .. " " .. j) --16 angles
  1002. emu.frameadvance()
  1003. joypad.set({["A Up"]=true},1)
  1004. gui.text(100,130,"Iteration: " .. k .. " " .. j) --16 angles
  1005. emu.frameadvance()
  1006. joypad.set({["A Up"]=true},1)
  1007. gui.text(100,130,"Iteration: " .. k .. " " .. j) --16 angles
  1008. emu.frameadvance()
  1009. joypad.set({["A Up"]=true},1)
  1010. gui.text(100,130,"Iteration: " .. k .. " " .. j) --16 angles
  1011. emu.frameadvance()
  1012.  
  1013. EnemiesLeft = memory.readbyte(0x07C993, "RDRAM")
  1014.  
  1015. ThisR = getNextRNG(ThisR)
  1016. --=20*(W4/22.5)+(V4-20)+180
  1017.  
  1018. if EnemiesLeft > 0 then
  1019. io.write("1\n") -- Got into battle
  1020. else
  1021. io.write("0\n")
  1022. end
  1023.  
  1024. end -- End inner loop
  1025. io.output():close()
  1026. startEnc = startEnc + 50
  1027. end -- End outer loop
  1028. end -- End function
  1029.  
  1030. -- Initializations
  1031. local i
  1032. globalLvTable = {}
  1033. globalLvTable = setupLvTable(globalLvTable)
  1034. globalStatTable = {}
  1035. globalStatTable = setupStatTable(globalStatTable)
  1036. memory.usememorydomain("RDRAM")
  1037. RNGTableGlobal = {}
  1038.  
  1039. ----------------------------
  1040. --Changes go down here.--
  1041. ----------------------------
  1042.  
  1043. local tmp
  1044. --for i=0x1,0xFFFF00 do
  1045. --if memory.readbyte(i) == 9 then
  1046. --if memory.readbyte(i+1) == 9 and memory.readbyte(i+2) == 9 and memory.readbyte(i+3) == 9 then
  1047. --end
  1048. --end
  1049.  
  1050. --memory.writebyte(0x07BAB4, 10, "RDRAM")
  1051. --HP50()
  1052. --setSpirits(48,48,48,48)
  1053. --setStats(200,100,250,20) -- HP MP De Ag
  1054. --heatMapGenerator()
  1055. makeDumpFile = false
  1056. generateRNGTable(makeDumpFile)
  1057. --avalancheBasher()
  1058. --encounterRateBasher()
  1059.  
  1060. --memory.write_u32_be(0x04D748, 1, "RDRAM") -- RNG
  1061.  
  1062. PrevRNG = 0
  1063. PrevRNG2 = 0
  1064. PrevRNG3 = 0
  1065. BufRNG3 = 0
  1066. BufRNG2 = 0
  1067. BufRNG = 0
  1068. encZState = 0
  1069. zLockout = 0
  1070. encAggregate = 0
  1071.  
  1072. Last1 = 1
  1073. Last2 = 1
  1074. Last3 = 1
  1075. Last4 = 1
  1076. Last5 = 1
  1077.  
  1078. calculateJoystickTableAngle()
  1079. -- To print usable buttons, use the following
  1080. --console.log( joypad.getimmediate() )
  1081.  
  1082. while true do
  1083.  
  1084. --memory.write_u32_be(0x7508C, 0, "RDRAM") -- did this do something?
  1085. --memory.write_u16_be(0x22FE2, 0, "RDRAM") --41C6 --0 FREEZES RNG
  1086. --memory.write_u16_be(0x22FE4, 10001, "RDRAM")
  1087. --memory.write_u16_be(0x22FE6, 0, "RDRAM") --4E6D --0 FREEZES RNG
  1088. --memory.write_u32_be(0x04D748, 29, "RDRAM") -- RNG
  1089.  
  1090. CalcNextRNG()
  1091.  
  1092. -- High Byte: =(65536* (A*B + RNG_HIGH * 2*C) * (C * C + 1)
  1093. -- Low Byte: =(B * (C + 1) + C*C*RNG_LOW)
  1094. --Start = 0. A = 0, B = 12345, C = 3
  1095. --0
  1096. --49380
  1097. --493800
  1098. --4493580
  1099. --40491600
  1100.  
  1101. --0 goes to 37035
  1102. --1 goes to 37039
  1103. --2 goes to 37043
  1104. --3 goes to 37047
  1105. --4 goes to 37051
  1106.  
  1107. --E4 is adder. E6 of 1 adds 2x adder.
  1108.  
  1109. --0,7,68,617,5561,50053
  1110. --X*3+1
  1111.  
  1112. --X*0 + Y
  1113. --X*1 + Y
  1114.  
  1115. --RNG increment 0,N,1 rotates in a circle around you.
  1116. --RNG increment 0,0,0 stays in one spot
  1117.  
  1118. --Thing1
  1119. --memory.writefloat(0x86FA4, 1600, true, "RDRAM")
  1120. --memory.write_u32_be(0x4D748, 0, "RDRAM")
  1121. stackOfJewelsAndWings()
  1122. --HP50()
  1123. --highEncounterCounter()
  1124. --memory.writebyte(0x07CAB2,0,"RDRAM")
  1125. --memory.writebyte(0x07CAB5,0,"RDRAM")
  1126. --memory.writebyte(0x07CAB4,0,"RDRAM")
  1127. --memory.writebyte(0x07CAB3,0,"RDRAM")
  1128. --freezeEncounterCounter()
  1129. printEnemyStats(50,10)
  1130. --printObjectCoordinates(50,10)
  1131. toggleEncounterCounterWithZ()
  1132. printEncounterCounter(100,500)
  1133. --maxEncounterCounter()
  1134. --printStats(100,420)
  1135. --printLocation(100,45)
  1136. --printAgility(100,230)
  1137. --printItems(500,250)
  1138. --howManyRocksCurrently(500,100)
  1139. --printMemoryDomains(100,115)
  1140. --printLvTable(100,115,globalLvTable)
  1141. --printStatTable(100,115,globalStatTable)
  1142.  
  1143. --RNG 2480
  1144. --2209236614
  1145.  
  1146. emu.frameadvance()
  1147. end
Advertisement
Add Comment
Please, Sign In to add comment