Advertisement
Kirkq

Quest 64 Lua Script 2/5/17

Feb 5th, 2017
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.58 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. Speed = math.sqrt(XSpeed * XSpeed + YSpeed * YSpeed)
  23. gui.text(x,y + 0,"X: " .. round(memory.readfloat(0x7BACC, true, "RDRAM"),4))
  24. gui.text(x,y+15,"Y: " .. round(memory.readfloat(0x7BAD4, true, "RDRAM"),4))
  25. gui.text(x,y+30,"XSpeed: " .. round(XSpeed,4))
  26. gui.text(x,y+45,"YSpeed: " .. round(YSpeed,4))
  27. gui.text(x,y+60,"Speed: " .. round(Speed,4))
  28. end
  29. --84EE6 and 84EEE strongly related to "area/zone or maybe music"
  30. --memory.write_u16_be(0x084EE6, 2, "RDRAM")
  31. --memory.write_u16_be(0x084EEE, 2, "RDRAM")
  32. --memory.write_u16_be(0x08536A, 2, "RDRAM")
  33.  
  34. function printItems(x,y)
  35. for i=1,30 do
  36. Item = memory.readbyte(0x8CF78 + (i -1), "RDRAM")
  37. if Item ~= 255 and Item <= 25 then
  38. gui.text(x,y + 15*(i-1), "Item:" .. globalItemList[Item+1])
  39. end
  40. end
  41. end
  42.  
  43. function printAgility (x,y)
  44. --gui.text(x,y + 15*0,"Agi(?): " .. round(memory.readfloat(0x7BC14, true, "RDRAM"),4))
  45. --gui.text(x+200,y + 15*0,"/800")
  46. gui.text(x,y + 15*1,"AgiField: " .. round(memory.readfloat(0x7BC18, true, "RDRAM"),4))
  47. gui.text(x+200,y + 15*1,"/1000")
  48. gui.text(x,y+15*2,"AgiTown: " .. round(memory.readfloat(0x7BC1C, true, "RDRAM"),4))
  49. gui.text(x+200,y + 15*2,"/2000")
  50. gui.text(x,y+15*3,"AgiBattle:" .. round(memory.readfloat(0x7BCA0, true, "RDRAM"),4))
  51. gui.text(x+200,y + 15*3,"/50")
  52. gui.text(x,y+15*4,"MPRecharge: " .. round(memory.readfloat(0x7BC0C, true, "RDRAM"),4))
  53. gui.text(x+200,y + 15*4,"/35")
  54.  
  55. --gui.text(x,y+15*3,"Camera: " .. round(memory.readfloat(0x85D3C, true, "RDRAM"),4))
  56. --gui.text(x,y+15*4,"Camera: " .. round(memory.readfloat(0x85DAC, true, "RDRAM"),4))
  57. --gui.text(x,y+15*5,"Camera: " .. round(memory.readfloat(0x85DE4, true, "RDRAM"),4))
  58. --gui.text(x,y+15*6,"Camera: " .. round(memory.readfloat(0x85E54, true, "RDRAM"),4))
  59. gui.text(x,y+15*7,"BattleLastX: " .. round(memory.readfloat(0x86B18, true, "RDRAM"),4))
  60. --gui.text(x,y+15*8,"BattleLastZ: " .. round(memory.readfloat(0x86B1C, true, "RDRAM"),4))
  61. gui.text(x,y+15*8,"BattleLastY: " .. round(memory.readfloat(0x86B20, true, "RDRAM"),4))
  62. gui.text(x,y+15*9,"CameraCenteredHereX: " .. round(memory.readfloat(0x86DD8, true, "RDRAM"),4))
  63. --gui.text(x,y+15*9,"CameraCenteredHereZ: " .. round(memory.readfloat(0x86DDC, true, "RDRAM"),4))
  64. gui.text(x,y+15*10,"CameraCenteredHereY: " .. round(memory.readfloat(0x86DE0, true, "RDRAM"),4))
  65. --gui.text(x,y+15*9,"ArenaX: " .. round(memory.readfloat(0x88188, true, "RDRAM"),4))
  66. --gui.text(x,y+15*10,"ArenaX: " .. round(memory.readfloat(0x881B8, true, "RDRAM"),4))
  67. --gui.text(x,y+15*11,"ArenaX: " .. round(memory.readfloat(0x8C5A4, true, "RDRAM"),4))
  68. end
  69.  
  70. function printEncounterCounter(x,y)
  71. gui.text(x,y,"EncCount: " .. memory.read_u16_be(0x8C578, "RDRAM"))
  72. --You can cheese 1.9 pixels as it rolls over.
  73. gui.text(x+190,y,"/2000")
  74. gui.text(x,y + 15,"Increment: " .. round(memory.readfloat(0x8C574, true, "RDRAM"),4))
  75. RNG_EC = memory.read_u32_be(0x4D748, "RDRAM")
  76. gui.text(x,y + 30, "RNG: " .. RNG_EC .. " = " .. string.format("%08X ", RNG_EC))
  77. gui.text(x,y + 45, "A: " .. memory.read_u16_be(0x22FE2, "RDRAM"))
  78. gui.text(x,y + 60, "B: " .. memory.read_u16_be(0x22FE4, "RDRAM") - 1000)
  79. gui.text(x,y + 75, "C: " .. memory.read_u16_be(0x22FE6, "RDRAM"))
  80. end
  81.  
  82. function freezeEncounterCounter()
  83. memory.write_u16_be(0x8C578, 0, "RDRAM")
  84. memory.writefloat(0x8C574, 0, true, "RDRAM")
  85. end
  86.  
  87. function highEncounterCounter()
  88. memory.write_u16_be(0x8C578, 1800,"RDRAM")
  89. end
  90.  
  91. function printEnemyStats(x,y)
  92. EnemiesLeft = memory.readbyte(0x07C993, "RDRAM")
  93. TimeUntilYouAct = memory.read_u16_be(0x07C99A, "RDRAM")
  94.  
  95. gui.text(x,y,"ToAct:" .. TimeUntilYouAct)
  96.  
  97. NumEnemies = EnemiesLeft -- For Now, Not Ideal
  98. if NumEnemies > 0 then
  99. for i=1,NumEnemies do
  100. Base = 0x07C99C --next = 0x07CAC4
  101. WalkDec1 = memory.read_u16_be(0x07C99C + 296*(i-1), "RDRAM")
  102. RelatedToAttacking = memory.read_u16_be(0x07C99E + 296*(i-1), "RDRAM")
  103. RelatedToAttacking2 = memory.read_u16_be(0x07C9A0 + 296*(i-1), "RDRAM")
  104. FloatSomething = memory.readfloat(0x7C9A8 + 296*(i-1), true, "RDRAM")
  105. CurrHP = memory.read_u16_be(0x07C9A2 + 296*(i-1), "RDRAM") --9A2 and ACA and BF2 --7C993 = dead? 3 = alive, 2 = dead? (296 = 0x128)
  106. MaxHP = memory.read_u16_be(0x07C9A4 + 296*(i-1), "RDRAM")
  107. X = memory.readfloat(0x7C9BC + 296*(i-1), true, "RDRAM")
  108. Z = memory.readfloat(0x7C9C0 + 296*(i-1), true, "RDRAM")
  109. Y = memory.readfloat(0x7C9C4 + 296*(i-1), true, "RDRAM")
  110.  
  111. RapidlyChanging1 = memory.read_u16_be(0x07C9C6 + 296*(i-1), "RDRAM")
  112. RapidlyChanging2 = memory.read_u16_be(0x07C9D4 + 296*(i-1), "RDRAM")
  113. RapidlyChanging3 = memory.read_u16_be(0x07C9D6 + 296*(i-1), "RDRAM")
  114. RapidlyChanging4 = memory.read_u16_be(0x07C9DC + 296*(i-1), "RDRAM")
  115. RapidlyChanging5 = memory.read_u16_be(0x07C9DE + 296*(i-1), "RDRAM")
  116.  
  117. SizeModifier = memory.readfloat(0x7C9E0 + 296*(i-1), true, "RDRAM")
  118. --memory.writefloat(0x7C9E0, 0.4, true, "RDRAM") -- Meme Address
  119. TrueSize = memory.readfloat(0x7C9E4 + 296*(i-1), true, "RDRAM")
  120. Float3 = memory.readfloat(0x7C9E8 + 296*(i-1), true, "RDRAM")
  121. Float4 = memory.readfloat(0x7C9EC + 296*(i-1), true, "RDRAM")
  122. Float5 = memory.readfloat(0x7C9F0 + 296*(i-1), true, "RDRAM")
  123.  
  124.  
  125. --Hell Hound: Anything below 20.9 distance from center to center."
  126. --Were Hare less than 15.6 hits. Difference of 5.3
  127.  
  128. --Hell Hound sphere of influence is about 27.0
  129. -- 0.084
  130. -- 130
  131. -- 130 * 0.084 = 10.92
  132. -- -1.428
  133. -- 1
  134. -- 120
  135.  
  136. -- 0.07
  137. -- 80
  138. -- 80 * 0.07 = 5.6
  139. -- 0.2275
  140. -- 1
  141. -- 120
  142.  
  143.  
  144. ID = memory.readbyte(0x07CA0D + 296*(i-1), "RDRAM") --A0D
  145.  
  146. RapidlyChanging6 = memory.read_u16_be(0x07CA10 + 296*(i-1), "RDRAM")
  147. RapidlyChanging7 = memory.read_u16_be(0x07CA12 + 296*(i-1), "RDRAM")
  148. RelatedToAttacking3 = memory.readbyte(0x07CA19+ 296*(i-1), "RDRAM")
  149. Dunno1 = memory.readbyte(0x07CA1B+ 296*(i-1), "RDRAM")
  150. Atk = memory.read_u16_be(0x07CAAC + 296*(i-1), "RDRAM")
  151. Agi = memory.read_u16_be(0x07CAAE + 296*(i-1), "RDRAM")
  152. Def= memory.read_u16_be(0x07CAB0 + 296*(i-1), "RDRAM")
  153. --Exp does not appear to be here. Total Exp for battle maybe?
  154.  
  155. gui.text(x+100*(i-1),y+15,"HP:" .. CurrHP .. "/" .. MaxHP)
  156. gui.text(x+100*(i-1),y+30,"At:" .. Atk)
  157. gui.text(x+100*(i-1),y+45,"De:" .. Def)
  158. gui.text(x+100*(i-1),y+60,"Ag:" .. Agi)
  159. gui.text(x+100*(i-1),y+75,"ID:" .. ID)
  160. gui.text(x+100*(i-1),y+90,"WalkDec:" .. WalkDec1)
  161. gui.text(x+100*(i-1),y+105,"Size:" .. round(SizeModifier*TrueSize,4))
  162. --gui.text(x+100*(i-1),y+120,"3:" .. Dunno3)
  163. end
  164. end
  165. end
  166.  
  167.  
  168. --Solvaring
  169. --Zelse
  170. --Nepty
  171. --Shilf
  172. --Fargo
  173. --Guilty
  174. --Beigis Stats in ROM at D87944
  175. --Mammon in ROM at D8797C --Offset is 0x38
  176. --*
  177. --*
  178. --6 areas and bosses
  179. --
  180. --0x112664 07D0BF 07D0AF 07D0AE 07D0AD 07D0AA 07D0A9
  181. --1 96 68 9 39 8 39
  182. --0 116 112 90 41 89 41
  183. --255 136 184 144 38 144 38
  184. --0 156 164 32 40 31 40
  185. --0 176 192 140 39 140 39
  186.  
  187. --39 39 39 39 39 8 144 39 9 68 96 65 141
  188. --41 41 41 41 41 89 144 41 90 112 116 129 147
  189.  
  190. --Were Hare ADC094 80, 140, 0.07
  191. --Hell Hound 130, 170, 0.084
  192. --Man Eater 115, 135, 0.084
  193. --Big Mouth ADC13C 130, 70, 0.105
  194. --Parassault 90, 150, 0.077
  195. --Orc Jr 90, 150, 0.077
  196. --Gremlin 90, 140, 0.084
  197. --Skeleton 90, 135, 0.084
  198. --Ghost Hound 90, 238, 0.084
  199. --Merrow 130, 170, 0.084
  200. --Wolf Goat 80, 125, 0.084, 130, 170, 0.091
  201. --*
  202. --Goblin B6337C
  203. --Frog King
  204. --Apophis
  205. --Mad Doll
  206. --Death Hugger
  207. --Kobold
  208. --Man Trap
  209. --Bat
  210. --Frog Knight
  211. --Marionasty
  212. --Dark Goblin
  213. --Hot Lips
  214. --Ghost Stalker B6361C
  215. --Treant
  216. --Cockatrice
  217. --*
  218. --Multi-Optics BBDE9C
  219. --Mimic
  220. --Crawler
  221. --Scorpion
  222. --Scare Crow
  223. --Wyvern
  224. --Skelebat
  225. --Cryshell BBE024
  226. --Blood Jell
  227. --Caterpillar (9) -- C7D935 is interesting, may be red herring
  228. --Fish Man
  229. --*
  230. --Sandman (ID 0) C317EC
  231. --Werecat
  232. --Nightmare
  233. --Blue Man
  234. --Winged Sunfish
  235. --Gloon Wing
  236. --Ogre (ID 6)
  237. --Rocky (ID 7)
  238. --Red Wyvern
  239. --FlamedMane
  240. --Magma Fish
  241. --RedRose (ID 11)
  242. --WhiteRoseKnight: C31A8C
  243. --*
  244. --Orc C9BE54
  245. --Ghost C9BE8C
  246. --Will o Wisp
  247. --Sprite
  248. --JackoLantern
  249. --Arachnoid
  250. --Lamia
  251. --Temptress
  252. --Pixie
  253. --Grangach
  254. --Thunder Jell
  255. --Termant
  256. --*
  257. --Judgment HP: CC443C
  258. --Pin Head HP: CC44AC
  259. --Pale Rider: CC4474
  260. --Spriggan: CC44E4
  261.  
  262. --RNG ROM
  263. --023BE2 =16838 and 023BE6 = 20077
  264. --41C64E6Dh + 3039h
  265. --12345 or 13345 ??
  266. --023BE4
  267.  
  268. --RNG RAM
  269. --022FE0
  270. --memory.write_u16_be(0x22FE2, 0, "RDRAM")
  271. --memory.write_u16_be(0x22FE4, 300, "RDRAM")
  272. --memory.write_u16_be(0x22FE6, 0, "RDRAM")
  273.  
  274. --Avalanche Y starts at 0x86F2C
  275.  
  276. function printStats(x,y)
  277. local Exp = memory.read_u32_be(0x07BA90, "RDRAM")
  278. local HPLv = memory.readbyte(0x07BAB0, "RDRAM")
  279. local MPLv = memory.readbyte(0x07BAB1, "RDRAM")
  280. local AgiLv = memory.readbyte(0x07BAB2, "RDRAM")
  281. local DefLv = memory.readbyte(0x07BAB3, "RDRAM")
  282. local Lv = memory.readbyte(0x07BAB4, "RDRAM")
  283. local CurrHP = memory.read_u16_be(0x7BA84, "RDRAM")
  284. local MaxHP = memory.read_u16_be(0x7BA86, "RDRAM")
  285. local HPSub = memory.readbyte(0x7BAA9, "RDRAM")
  286. local CurrMP = memory.read_u16_be(0x7BA88, "RDRAM")
  287. local MaxMP = memory.read_u16_be(0x7BA8A, "RDRAM")
  288. local MPSub = memory.readbyte(0x7BAAB, "RDRAM")
  289. local Def = memory.readbyte(0x7BA8F, "RDRAM")
  290. local DefSub = memory.readbyte(0x7BAAF, "RDRAM")
  291. local Agi = memory.readbyte(0x7BA8D, "RDRAM")
  292. local AgiSub = memory.readbyte(0x7BAAD, "RDRAM")
  293. gui.text(x,y+0,"HP: " .. CurrHP .. "/" .. MaxHP .. " (" .. HPSub .. "/" .. globalStatTable[HPLv+1] ..")")
  294. gui.text(x,y+15,"MP: " .. CurrMP .. "/" .. MaxMP .. " (" .. MPSub .. "/" .. 4*globalStatTable[MPLv+1] ..")")
  295. gui.text(x,y+30,"Def: " .. Def .. " (" .. DefSub .. "/" .. 2*globalStatTable[DefLv+1] ..")")
  296. gui.text(x,y+45,"Agi: " .. Agi .. " (" .. AgiSub .. "/" .. globalStatTable[AgiLv+1] ..")")
  297. gui.text(x,y+60,"Lv: " .. Lv .. " (" .. Exp .. "/" .. globalLvTable[Lv+1] .. ")")
  298. end
  299.  
  300. function HP50()
  301. memory.write_u16_be(0x7BA84, 50, "RDRAM")
  302. end
  303. function setSpirits(f,e,wa,wi)
  304. memory.writebyte(0x7BAA4, f, "RDRAM")
  305. memory.writebyte(0x7BAA5, e, "RDRAM")
  306. memory.writebyte(0x7BAA6, wa, "RDRAM")
  307. memory.writebyte(0x7BAA7, wi, "RDRAM")
  308. end
  309. function setStats(HP,MP,De,Ag)
  310. memory.write_u16_be(0x7BA86, HP, "RDRAM")
  311. memory.write_u16_be(0x7BA8A, MP, "RDRAM")
  312. memory.writebyte(0x7BA8F, De, "RDRAM")
  313. memory.writebyte(0x7BA8D, Ag, "RDRAM")
  314. end
  315. function stackOfJewelsAndWings()
  316. --Earth Orb opens Connor Fortress door.
  317. --Wind Jade opens door to access Blue Cave.
  318. --Water Jewel reopens ship.
  319. memory.writebyte(0x8CF78, 20, "RDRAM")
  320. memory.writebyte(0x8CF79, 21, "RDRAM")
  321. memory.writebyte(0x8CF7A, 22, "RDRAM")
  322. memory.writebyte(0x8CF7B, 14, "RDRAM")
  323. memory.writebyte(0x8CF7C, 15, "RDRAM")
  324. memory.writebyte(0x8CF7D, 16, "RDRAM")
  325. memory.writebyte(0x8CF7E, 17, "RDRAM")
  326. memory.writebyte(0x8CF7F, 18, "RDRAM")
  327. memory.writebyte(0x8CF80, 19, "RDRAM")
  328. end
  329.  
  330. function setupLvTable(tmpTable)
  331. --This table is calculated off the current level.
  332. local i
  333. for i=1,99 do
  334. tmpTable[i] = memory.read_u32_be(0x05493C+4*(i-1),"ROM")
  335. end
  336. return tmpTable
  337. end
  338. function printLvTable(x,y,tmpTable)
  339. local i
  340. for i=1,99 do
  341. gui.text(x,y+i*15,tmpTable[i])
  342. end
  343. end
  344. function setupStatTable(tmpTable1)
  345. --This table is calculated off the concept of numStatLevels, not current level.
  346. local i
  347. for i=1,70 do
  348. tmpTable1[i] = memory.read_u16_be(0x054ACC+2*(i-1),"ROM")
  349. end
  350. return tmpTable1
  351. end
  352. function printStatTable(x,y,tmpTable1)
  353. --ROM 0x054909 is starting stats I think?
  354. local i
  355. for i=1,70 do
  356. gui.text(x,y+i*15,tmpTable1[i])
  357. end
  358. end
  359.  
  360. function printObjectCoordinates(x,y)
  361. --memory.writefloat(0x86F2C, 1600, true, "RDRAM")
  362. BrianX = memory.readfloat(0x7BACC, true, "RDRAM")
  363. BrianY = memory.readfloat(0x7BAD4, true, "RDRAM")
  364.  
  365. i = 1 --Enemy number 1 (starting at 1)
  366. EnemyX = memory.readfloat(0x7C9BC + 296*(i-1), true, "RDRAM")
  367. EnemyY = memory.readfloat(0x7C9C4 + 296*(i-1), true, "RDRAM")
  368.  
  369. for i=1,10 do
  370. --memory.writefloat(0x86F24 + 60*(i-1), -20, true, "RDRAM") --X
  371. --memory.writefloat(0x86F2C + 60*(i-1), -350, true, "RDRAM") --Y
  372.  
  373. --RightSide -1367,930
  374. --LeftSide -1327, 930
  375. --BackSide -1347, 948
  376. --FrontSide -1347, 908
  377.  
  378. --Hell Hound: Anything below 20.9 distance from center to center."
  379. --Were Hare less than 15.6 hits.
  380. --
  381. --Solvaring 10 + 8.4 Note: Solvaring is moving about half a pixel during standing.
  382. --Zelse 10 + 5.6 (Investigate Zelse Mid-Range) Zelse moves about 0.4 pixels during standing. He recoils a couple pixels when hit.
  383. --Nepty 10 + 4.9 Nepty moves about 0.4 px during standing.
  384. --Shilf 10 + 4.9 Shilf moves about 0.05
  385. --Fargo 10 + 7 moves about 0.05
  386. --Guilty 10 + 9.52 No movement
  387. --Beigis 10 + 6.3 No movement
  388. --Mammon 10 + 94.5 Moves around 0.6 px.
  389.  
  390. Timer = memory.read_u16_be(0x86F1C + 60*(i-1), "RDRAM")
  391. X = memory.readfloat(0x86F24 + 60*(i-1), true, "RDRAM")
  392. Z = memory.readfloat(0x86F28 + 60*(i-1), true, "RDRAM")
  393. Y = memory.readfloat(0x86F2C + 60*(i-1), true, "RDRAM")
  394. XDiff= BrianX - X
  395. YDiff= BrianY - Y
  396. D = math.sqrt(XDiff*XDiff + YDiff*YDiff)
  397. A = math.atan2(XDiff,YDiff)*(180/(math.pi))
  398. EnemyXDiff = EnemyX - X
  399. EnemyYDiff = EnemyY - Y
  400. EnemyD = math.sqrt(EnemyXDiff*EnemyXDiff + EnemyYDiff*EnemyYDiff)
  401. EnemyA = math.atan2(EnemyXDiff,EnemyYDiff)*(180/(math.pi))
  402.  
  403.  
  404.  
  405. j=0
  406. if i > 5 then
  407. j=1
  408. end
  409.  
  410. if (Timer > 0) then
  411. gui.text(x+140*(i-j*5-1),y+0*15 + j*100,"Timer: " .. Timer)
  412. gui.text(x+140*(i-j*5-1),y+1*15 + j*100,"X: " .. round(X,3))
  413. gui.text(x+140*(i-j*5-1),y+2*15 + j*100,"Z: " .. round(Z,3))
  414. gui.text(x+140*(i-j*5-1),y+3*15 + j*100,"Y: " .. round(Y,3))
  415. gui.text(x+140*(i-j*5-1),y+4*15 + j*100,"D: " .. round(D,3))
  416. gui.text(x+140*(i-j*5-1),y+5*15 + j*100,"A: " .. round(A,3)) --16 angles
  417. --gui.text(x+140*(i-j*5-1),y+4*15 + j*100,"D: " .. round(EnemyD,3))
  418. --gui.text(x+140*(i-j*5-1),y+5*15 + j*100,"A: " .. round(EnemyA,3))
  419. end
  420. end
  421.  
  422.  
  423. --F1C Timer
  424. --F24 X
  425. --F28 Z
  426. --F2C Y
  427.  
  428. --F60 X
  429. --F64 Z
  430. --F68 Y
  431. end
  432.  
  433. function rocksBrianToEnemy(BrianX1,BrianY1,EnemyX1,EnemyY1,Size1)
  434.  
  435. numRocks1 = 0
  436.  
  437. --textfile = "BizDump2"
  438. --dumpfile = textfile..".txt"
  439. --io.output(dumpfile)
  440.  
  441.  
  442. for i=0,15 do --Angles
  443. for j=20,39 do --Distances
  444. thisRockX1= BrianX1 + j*math.cos(i*22.5*math.pi/180)
  445. thisRockY1= BrianY1 + j*math.sin(i*22.5*math.pi/180)
  446.  
  447. XDiff1= thisRockX1 - EnemyX1
  448. YDiff1= thisRockY1 - EnemyY1
  449. D1 = math.sqrt(XDiff1*XDiff1 + YDiff1*YDiff1)
  450. if D1 <= Size1 + 10 then
  451. numRocks1 = numRocks1 + 1
  452. --io.write(thisRockX1, " ", thisRockY1, " ", i, " ", j, "\n")
  453. end
  454.  
  455. end
  456. end
  457.  
  458. --io.output():close()
  459.  
  460. return numRocks1
  461. end
  462.  
  463. function howManyRocksCurrently(x,y)
  464. BrianX = memory.readfloat(0x7BACC, true, "RDRAM")
  465. BrianY = memory.readfloat(0x7BAD4, true, "RDRAM")
  466. i = 1 --Enemy number 1 (starting at 1)
  467. EnemyX = memory.readfloat(0x7C9BC + 296*(i-1), true, "RDRAM")
  468. EnemyY = memory.readfloat(0x7C9C4 + 296*(i-1), true, "RDRAM")
  469. SizeModifier = memory.readfloat(0x7C9E0 + 296*(i-1), true, "RDRAM")
  470. TrueSize = memory.readfloat(0x7C9E4 + 296*(i-1), true, "RDRAM")
  471. Size = SizeModifier*TrueSize
  472. XDiff= BrianX - EnemyX
  473. YDiff= BrianY - EnemyY
  474. D = math.sqrt(XDiff*XDiff + YDiff*YDiff)
  475. A = math.atan2(XDiff,YDiff)*(180/(math.pi))
  476.  
  477. R = rocksBrianToEnemy(BrianX,BrianY,EnemyX,EnemyY,Size)
  478.  
  479. gui.text(x,y+15*0,"D: " .. round(D,3))
  480. gui.text(x,y+15*1,"A: " .. round(A,3))
  481. gui.text(x,y+15*2,"Size:" .. round(Size))
  482. gui.text(x,y+15*3,"NumRocks:" .. R)
  483. gui.text(x,y+15*4,"BrianX:" .. BrianX)
  484. gui.text(x,y+15*5,"BrianY:" .. BrianY)
  485. gui.text(x,y+15*6,"EnemyX:" .. EnemyX)
  486. gui.text(x,y+15*7,"EnemyY:" .. EnemyY)
  487.  
  488. end
  489.  
  490. function heatMapGenerator()
  491. MapSize = 120
  492. BrianX = math.floor(MapSize/2)
  493. BrianY = math.floor(MapSize/2)
  494. Size = 6.3
  495. --Solvaring 10 + 8.4 Note: Solvaring is moving about half a pixel during standing.
  496. --Zelse 10 + 5.6 (Investigate Zelse Mid-Range) Zelse moves about 0.4 pixels during standing. He recoils a couple pixels when hit.
  497. --Nepty 10 + 4.9 Nepty moves about 0.4 px during standing.
  498. --Shilf 10 + 4.9 Shilf moves about 0.05
  499. --Fargo 10 + 7 moves about 0.05
  500. --Guilty 10 + 9.52 No movement
  501. --Beigis 10 + 6.3 No movement
  502. --Mammon 10 + 94.5 Moves around 0.6 px.
  503. heatTextfile = "HeatMap"
  504. heatDumpfile = heatTextfile..".txt"
  505. io.output(heatDumpfile)
  506.  
  507. Max = 0
  508.  
  509. for EnemyX=0,MapSize do
  510. for EnemyY=MapSize,0,-1 do
  511. R = rocksBrianToEnemy(BrianX,BrianY,EnemyX,EnemyY,Size)
  512. if R > Max then
  513. Max = R
  514. end
  515. io.write(string.format("%02X ", R))
  516. end
  517. io.write("\n")
  518. end
  519.  
  520. io.write("\n")
  521. io.write("EnemySize: " .. Size)
  522. io.write("\n")
  523. io.write("Max: ", string.format("%02X", Max))
  524. io.write("\n")
  525. io.write("MapSize: " .. MapSize+1)
  526.  
  527. io.output():close()
  528.  
  529.  
  530. end
  531.  
  532. globalItemList = {
  533. "0. Spirit Light",
  534. "1. Fresh Bread",
  535. "2. Honey Bread",
  536. "3. Healing Potion",
  537. "4 Dragon's Potion",
  538. "5. Dew Drop",
  539. "6. Mint Leaves",
  540. "7. Heroes Drink",
  541. "8. Silent Flute",
  542. "9.Celine's Bell",
  543. "10.Replica",
  544. "11.Giant's Shoes",
  545. "12.Silver Amulet",
  546. "13.Golden Amulet",
  547. "14.White Wings",
  548. "15.Yellow Wings",
  549. "16.Blue Wings",
  550. "17.Green Wings",
  551. "18.Red Wings",
  552. "19.Black Wings",
  553. "20.Earth Orb",
  554. "21.Wind Jade",
  555. "22.Water Jewel",
  556. "23.Fire Ruby",
  557. "24.Eletale Book",
  558. "25.Dark Gaol Key",
  559. }
  560.  
  561. function CalcNextRNG()
  562. RNG1 = memory.read_u32_be(0x04D748, "RDRAM")
  563. Next1RNG = getNextRNG(RNG1)
  564. Next2RNG = getNextRNG(Next1RNG)
  565. Next3RNG = getNextRNG(Next2RNG)
  566.  
  567. --gui.text(400,490,"NextLo: " .. string.format("%08X ",R_LO2))
  568. --gui.text(400,505,"NextHi: " .. string.format("%08X ",R_HI2))
  569. gui.text(400,520,"NextRNG1: " .. string.format("%08X ", Next1RNG))
  570. gui.text(400,535,"NextRNG2: " .. string.format("%08X ", Next2RNG))
  571. gui.text(400,550,"NextRNG3: " .. string.format("%08X ", Next3RNG))
  572. gui.text(400,565,"BufRNG1: " .. string.format("%08X ", BufRNG))
  573. gui.text(400,580,"BufRNG2: " .. string.format("%08X ", BufRNG2))
  574. gui.text(400,595,"BufRNG3: " .. string.format("%08X ", BufRNG3))
  575.  
  576. if RNGTableGlobal[1]~= nil then
  577. for i=1,10000 do
  578. if RNG1 == RNGTableGlobal[i] then
  579. gui.text(400,610,"RNG Increment: " .. i)
  580. i = 1000000
  581. end
  582. end
  583. end
  584.  
  585. if PrevRNG ~= Next1RNG then
  586. BufRNG3 = PrevRNG3
  587. BufRNG2 = PrevRNG2
  588. BufRNG = PrevRNG
  589. PrevRNG3 = Next3RNG -- This is poorly buffered and doesn't quite work right, basically just a sanity check.
  590. PrevRNG2 = Next2RNG -- This is poorly buffered and doesn't quite work right, basically just a sanity check.
  591. PrevRNG = Next1RNG --Lol double buffer
  592. end
  593. end
  594.  
  595. function getNextRNG(passedRNG)
  596. A1 = memory.read_u16_be(0x22FE2, "RDRAM")
  597. B1 = memory.read_u16_be(0x22FE4, "RDRAM") - 1000
  598. C1 = memory.read_u16_be(0x22FE6, "RDRAM")
  599.  
  600. R_HI1 = math.floor(passedRNG/0x10000)
  601. R_LO1 = passedRNG % 0x10000
  602.  
  603. R_HI2 = A1 * R_LO1 + (R_HI1 * C1)
  604. R_HI2 = R_HI2 % 65536
  605. R_LO2 = R_LO1 * C1 + B1 --16,16,16
  606. passedRNG = (65536*R_HI2+R_LO2) % 0x100000000
  607.  
  608. return passedRNG
  609. end
  610.  
  611. function generateRNGTable(makeDumpfile)
  612.  
  613. RNGTextfile = "RNGDump"
  614. RNGDumpfile = RNGTextfile..".txt"
  615. if makeDumpfile then
  616. io.output(RNGDumpfile)
  617. startRNGSeed = 2209236614
  618. ThisR = startRNGSeed
  619. io.write(ThisR)
  620. io.write("\n")
  621. for i=2,10000 do
  622. ThisR = getNextRNG(ThisR)
  623. io.write(ThisR)
  624. io.write("\n")
  625. end
  626. io.output():close()
  627. end
  628.  
  629. RNGTextfile2 = "RNGDumpNextOrdered"
  630. RNGDumpfile2 = RNGTextfile2..".txt"
  631. if makeDumpfile then
  632. io.output(RNGDumpfile2)
  633. startRNGSeed = 1
  634. ThisR = getNextRNG(ThisR)
  635. io.write(ThisR)
  636. io.write("\n")
  637. for i=2,10000 do
  638. ThisR = i
  639. ThisR = getNextRNG(ThisR)
  640. io.write(ThisR)
  641. io.write("\n")
  642. end
  643. io.output():close()
  644. end
  645. --Make table
  646. startRNGSeed = 2209236614
  647. ThisR = startRNGSeed
  648. RNGTableGlobal[1] = ThisR
  649. for i=2,10000 do
  650. ThisR = getNextRNG(ThisR)
  651. RNGTableGlobal[i] = ThisR
  652. end
  653.  
  654. end
  655.  
  656. -- Initializations
  657. local i
  658. globalLvTable = {}
  659. globalLvTable = setupLvTable(globalLvTable)
  660. globalStatTable = {}
  661. globalStatTable = setupStatTable(globalStatTable)
  662. memory.usememorydomain("RDRAM")
  663. RNGTableGlobal = {}
  664.  
  665. ----------------------------
  666. --Changes go down here.--
  667. ----------------------------
  668.  
  669. local tmp
  670. --for i=0x1,0xFFFF00 do
  671. --if memory.readbyte(i) == 9 then
  672. --if memory.readbyte(i+1) == 9 and memory.readbyte(i+2) == 9 and memory.readbyte(i+3) == 9 then
  673. --end
  674. --end
  675.  
  676. --memory.writebyte(0x07BAB4, 10, "RDRAM")
  677. --HP50()
  678. setSpirits(38,39,40,41)
  679. setStats(200,100,250,250)
  680. --heatMapGenerator()
  681. makeDumpFile = false
  682. generateRNGTable(makeDumpFile)
  683.  
  684. --memory.write_u32_be(0x04D748, 0x00000000, "RDRAM") -- RNG
  685.  
  686. PrevRNG = 0
  687. PrevRNG2 = 0
  688. PrevRNG3 = 0
  689. BufRNG3 = 0
  690. BufRNG2 = 0
  691. BufRNG = 0
  692. while true do
  693.  
  694. --memory.write_u32_be(0x7508C, 0, "RDRAM") -- did this do something?
  695. --memory.write_u16_be(0x22FE2, 0, "RDRAM") --41C6
  696. --memory.write_u16_be(0x22FE4, 10001, "RDRAM")
  697. --memory.write_u16_be(0x22FE6, 0, "RDRAM") --4E6D
  698. memory.write_u32_be(0x04D748, 104, "RDRAM") -- RNG
  699.  
  700. CalcNextRNG()
  701.  
  702. -- High Byte: =(65536* (A*B + RNG_HIGH * 2*C) * (C * C + 1)
  703. -- Low Byte: =(B * (C + 1) + C*C*RNG_LOW)
  704. --Start = 0. A = 0, B = 12345, C = 3
  705. --0
  706. --49380
  707. --493800
  708. --4493580
  709. --40491600
  710.  
  711. --0 goes to 37035
  712. --1 goes to 37039
  713. --2 goes to 37043
  714. --3 goes to 37047
  715. --4 goes to 37051
  716.  
  717. --E4 is adder. E6 of 1 adds 2x adder.
  718.  
  719. --0,7,68,617,5561,50053
  720. --X*3+1
  721.  
  722. --X*0 + Y
  723. --X*1 + Y
  724.  
  725. --RNG increment 0,N,1 rotates in a circle around you.
  726. --RNG increment 0,0,0 stays in one spot
  727.  
  728. --Thing1
  729. --memory.writefloat(0x86FA4, 1600, true, "RDRAM")
  730. --memory.write_u32_be(0x4D748, 0, "RDRAM")
  731. stackOfJewelsAndWings()
  732. HP50()
  733. --highEncounterCounter()
  734. --memory.writebyte(0x07CAB2,0,"RDRAM")
  735. --memory.writebyte(0x07CAB5,0,"RDRAM")
  736. --memory.writebyte(0x07CAB4,0,"RDRAM")
  737. --memory.writebyte(0x07CAB3,0,"RDRAM")
  738. --freezeEncounterCounter()
  739. --printEnemyStats(50,10)
  740. printObjectCoordinates(50,10)
  741. printEncounterCounter(100,500)
  742. printStats(100,420)
  743. --printLocation(100,150)
  744. printAgility(100,230)
  745. printItems(400,250)
  746. howManyRocksCurrently(500,100)
  747. --printMemoryDomains(100,115)
  748. --printLvTable(100,115,globalLvTable)
  749. --printStatTable(100,115,globalStatTable)
  750.  
  751. --RNG 2480
  752. --2209236614
  753.  
  754. emu.frameadvance()
  755. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement