Guest User

frlglua

a guest
Dec 29th, 2012
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.70 KB | None | 0 0
  1. emu = emu or VBA
  2. if not emu then
  3. error("Run under VBA.")
  4. end
  5.  
  6. ransuu = {}
  7. shouhi = {}
  8. seed = {0, 0, 0, 0, 0}
  9. futureseed = {}
  10. frand = {}
  11. ran = 3 -- 0 or 3
  12. textcri = {}
  13.  
  14. function ransuuhyouji()
  15. f = emu.framecount()
  16. ransuu[f] = memory.readdword(0x03005040)
  17. for i = 1, 4 do
  18. shouhi[6 - i] = shouhi[5 - i]
  19. seed[6 - i] = seed[5 - i]
  20. end
  21. shouhi[1] = 0
  22. if seed[1] == nil then
  23. seed[1] = ransuu[f]
  24. shouhi[1] = 1
  25. end
  26. for i = 1, 80 do
  27. if seed[1] ~= ransuu[f] then
  28. seed1 = seed[1] % (2 ^ 16)
  29. seed2 = math.floor(seed[1] / (2 ^ 16))
  30. seed[1] = (((seed1 * 0x41C64E6D) + 0x6073) + ((seed2 * 0x41C64E6D) % (2 ^ 16) * (2 ^ 16))) % (2 ^ 32)
  31. shouhi[1] = shouhi[1] + 1
  32. rand = math.floor(seed[1] / 65536)
  33. if rand % 100 == 99 then
  34. colori = "red"
  35. elseif rand % 100 == 98 then
  36. colori = "yellow"
  37. elseif rand % 100 > 93 then
  38. colori = "purple"
  39. elseif rand % 100 > 89 then
  40. colori = "blue"
  41. else
  42. colori = "white"
  43. end
  44. if i < 17 then
  45. gui.text(2 ,40 + (i * 7) ,string.format("%x", rand))
  46. gui.text(24 ,40 + (i * 7) ,string.format(rand),colori)
  47. elseif i < 33 then
  48. gui.text(46 ,40 + ((i - 16) * 7) ,string.format(rand),colori)
  49. elseif i < 49 then
  50. gui.text(68 ,40 + ((i - 32) * 7) ,string.format(rand),colori)
  51. elseif i < 65 then
  52. gui.text(80 ,40 + ((i - 48) * 7) ,string.format(rand),colori)
  53. end
  54. end
  55. end
  56. if seed[1] ~= ransuu[f] then
  57. seed[1] = ransuu[f]
  58. shouhi[1] = 0
  59. end
  60.  
  61.  
  62. futureseed[1] = seed[1]
  63. for j = 2, 1001 do
  64. fseed1 = futureseed[j - 1] % (2 ^ 16)
  65. fseed2 = math.floor(futureseed[j - 1] / (2 ^ 16))
  66. futureseed[j] = (((fseed1 * 0x41C64E6D) + 0x6073) + ((fseed2 * 0x41C64E6D) % (2 ^ 16) * (2 ^ 16))) % (2 ^ 32)
  67. frand[j - 1] = math.floor(futureseed[j] / 65536)
  68. end
  69. pid = {}
  70. upper = {}
  71. downer = {}
  72. seibetuti = {}
  73. tokuseiti = {}
  74. kotaia = {}
  75. kotaib = {}
  76. kotaih = {}
  77. kotaic = {}
  78. kotaid = {}
  79. kotais = {}
  80. for i = 1, 5 do
  81. gui.text(2, 2 + (i * 7), shouhi[i])
  82. for j = 1, 4 do
  83. gui.text(0 + (18 * j), 2 + (i * 7), math.floor(seed[i] / 256 ^ (j - 1)) % 256)
  84. end
  85. end
  86.  
  87. -- kakushukeisan
  88.  
  89. --hitrate
  90. for m = 1, 10 do
  91. gui.text(115, 80 + (7 * m), frand[m] % 100)
  92. end
  93. gui.text (115, 73, "hit")
  94.  
  95. --critical
  96. cri = {}
  97. percent = {}
  98. l = 1
  99. for i = 1, 500 do
  100. if frand[i] % 16 == 0 then
  101. cri[l] = i
  102. percent[l] = 100 - (frand[i+7+ran] % 16)
  103. l = l + 1
  104. end
  105. end
  106. for k = 1, 10 do
  107. if cri[k] % 3 == 1 then
  108. textcri[k] = "*"
  109. else textcri[k] = ""
  110. end
  111. gui.text(130, 80 + (7 * k), cri[k] .. textcri[k])
  112. gui.text(146, 80 + (7 * k), percent[k].."%")
  113. end
  114. gui.text(130, 73, "crit")
  115.  
  116. --monohiroi
  117. hiroi = {}
  118. item = {}
  119. n = 1
  120. for i = 1, 499 do
  121. if frand[i] % 10 == 0 then
  122. hiroi[n] = i
  123. item[n] = frand[i + 1] % 100
  124. n = n + 1
  125. end
  126. end
  127. for o = 1, 10 do
  128. gui.text(160, 80 + (7 * o), hiroi[o])
  129. gui.text(180, 80 + (7 * o), item[o])
  130. end
  131. gui.text(160, 73, "mono")
  132. gui.text(180, 73, "item")
  133.  
  134. -- pokerus
  135. poke = {}
  136. p = 1
  137. col = "white"
  138. for i = 1, 1000 do
  139. if frand[i] % 0x4000 == 0 and frand[i] ~=0 then
  140. poke[p] = i
  141. p = p + 1
  142. col = "green"
  143. end
  144. end
  145. gui.text(200, 73, "pokerus")
  146. gui.text(200, 87, poke[1], col)
  147.  
  148. end
  149.  
  150.  
  151. function damagekeisan()
  152. local tekinumber = math.floor(memory.readbyte(0x02000073) / 16) + 1
  153. local mikatanumber = math.floor(memory.readbyte(0x02000070) / 16) + 1
  154. adamagemax = {}
  155. adamagemin = {}
  156. sdamagemax = {}
  157. sdamagemin = {}
  158. settei = {20, 30, 40, 50, 60, 80, 90, 95, 120, 135, 142, 150, 180, 225}
  159. level = memory.readbyte(0x020241E4 + 0x54+ (0x64 * (mikatanumber - 1)))
  160. kougeki = memory.readword(0x020241EA + 0x54+ (0x64 * (mikatanumber - 1)))
  161. tokukou = memory.readword(0x020241F0 + 0x54+ (0x64 * (mikatanumber - 1)))
  162. bougyo = memory.readword(0x02023FE8 + (0x64 * (tekinumber - 1)))
  163. tokubou = memory.readword(0x02023FEE + (0x64 * (tekinumber - 1)))
  164. function keisan(iryoku)
  165. adamagemax[iryoku] = (math.floor(math.floor((math.floor(level * 2 / 5) + 2) * iryoku * kougeki / bougyo) / 50) + 2)
  166. adamagemin[iryoku] = math.floor((math.floor(math.floor((math.floor(level * 2 / 5) + 2) * iryoku * kougeki / bougyo) / 50) + 2) * 85 / 100)
  167. sdamagemax[iryoku] = (math.floor(math.floor((math.floor(level * 2 / 5) + 2) * iryoku * tokukou / tokubou) / 50) + 2)
  168. sdamagemin[iryoku] = math.floor((math.floor(math.floor((math.floor(level * 2 / 5) + 2) * iryoku * tokukou / tokubou) / 50) + 2) * 85 / 100)
  169. end
  170. for i = 1, 14 do
  171. keisan(settei[i])
  172. gui.text(2, 55 + (i * 7), string.format("iryoku%d %d %d %d %d",settei[i], adamagemax[settei[i]], adamagemin[settei[i]], sdamagemax[settei[i]], sdamagemin[settei[i]]))
  173. end
  174. end
  175.  
  176. function kotaiseisei()
  177. for i = 1, 3 do
  178. pid[i] = math.floor(futureseed[4] / 65536) + (math.floor(futureseed[5 + math.floor(i / 3)] / 65536) * 65536) -- pid analyze
  179. gui.text(40 + 40 * math.floor(i / 3) ,49 ,string.format("%x",pid[i]))
  180. -- seikaku
  181. seikakuti = pid[i] % 25
  182. seikakuti24 = pid[i] % 24
  183. if 0 <= seikakuti and seikakuti <= 4 then
  184. upper[i] = "A"
  185. elseif 5 <= seikakuti and seikakuti <= 9 then
  186. upper[i] = "B"
  187. elseif 9 <= seikakuti and seikakuti <= 14 then
  188. upper[i] = "S"
  189. elseif 14 <= seikakuti and seikakuti <= 19 then
  190. upper[i] = "C"
  191. else
  192. upper[i] = "D"
  193. end
  194. if seikakuti % 5 == 0 then
  195. downer[i] = "A"
  196. elseif seikakuti % 5 == 1 then
  197. downer[i] = "B"
  198. elseif seikakuti % 5 == 2 then
  199. downer[i] = "S"
  200. elseif seikakuti % 5 == 3 then
  201. downer[i] = "C"
  202. else
  203. downer[i] = "D"
  204. end
  205. gui.text(22, 49 + (25 * i), seikakuti24)
  206.  
  207. -- seibetu
  208. seibetuti[i] = pid[i] % 256
  209. gui.text(22, 56 + (25 * i), seibetuti[i])
  210. -- tokusei
  211. tokuseiti[i] = pid[i] % 2
  212. gui.text(22 , 63 + (25 * i), tokuseiti[i])
  213. -- kotaiti
  214. kotaib[i] = math.floor(math.floor(futureseed[6 + AND(i, 2)] / 65536) / (2 ^ 10)) % 32
  215. kotaia[i] = math.floor(math.floor(futureseed[6 + AND(i, 2)] / 65536) / (2 ^ 5)) % 32
  216. kotaih[i] = math.floor(math.floor(futureseed[6 + AND(i, 2)] / 65536) / (2 ^ 0)) % 32
  217. kotaid[i] = math.floor(math.floor(futureseed[7 + AND(i, 2)] / 65536) / (2 ^ 10)) % 32
  218. kotaic[i] = math.floor(math.floor(futureseed[7 + AND(i, 2)] / 65536) / (2 ^ 5)) % 32
  219. kotais[i] = math.floor(math.floor(futureseed[7 + AND(i, 2)] / 65536) / (2 ^ 0)) % 32
  220. gui.text(40, 56 + (i * 25), string.format("%d %d %d %d %d %d", kotaih[i], kotaia[i], kotaib[i], kotaic[i], kotaid[i], kotais[i]))
  221. gui.text(40, 49 + (i * 25), upper[i], "red")
  222. gui.text(40, 63 + (i * 25), downer[i], "blue")
  223. end
  224. end
  225.  
  226. function enemykotaiti()
  227. local tekinumber = math.floor(memory.readbyte(0x02000073) / 16) + 1
  228. local mikatanumber = math.floor(memory.readbyte(0x02000070) / 16) + 1
  229. local natureorder={"Atk","Def","Spd","SpAtk","SpDef"}
  230. local naturename={
  231. "Hardy","Lonely","Brave","Adamant","Naughty",
  232. "Bold","Docile","Relaxed","Impish","Lax",
  233. "Timid","Hasty","Serious","Jolly","Naive",
  234. "Modest","Mild","Quiet","Bashful","Rash",
  235. "Calm","Gentle","Sassy","Careful","Quirky"}
  236. local typeorder={
  237. "Fighting","Flying","Poison","Ground",
  238. "Rock","Bug","Ghost","Steel",
  239. "Fire","Water","Grass","Electric",
  240. "Psychic","Ice","Dragon","Dark"}
  241.  
  242. local personality
  243. local trainerid
  244. local magicword
  245. local growthoffset
  246. local miscoffset
  247. local i
  248.  
  249. local species
  250. local ivs
  251. local hpiv
  252. local atkiv
  253. local defiv
  254. local spdiv
  255. local spatkiv
  256. local spdefiv
  257. local nature
  258. local natinc
  259. local natdec
  260. local hidpowbase
  261. local hidpowtype
  262.  
  263. personality=memory.readdwordunsigned(start)
  264. trainerid=memory.readdwordunsigned(start+4)
  265. magicword=bit.bxor(personality, trainerid)
  266.  
  267. i=personality%24
  268.  
  269. if i<=5 then
  270. growthoffset=0
  271. elseif i%6<=1 then
  272. growthoffset=12
  273. elseif i%2==0 then
  274. growthoffset=24
  275. else
  276. growthoffset=36
  277. end
  278.  
  279. if i>=18 then
  280. miscoffset=0
  281. elseif i%6>=4 then
  282. miscoffset=12
  283. elseif i%2==1 then
  284. miscoffset=24
  285. else
  286. miscoffset=36
  287. end
  288.  
  289. species=bit.band(bit.bxor(memory.readdwordunsigned(start+32+growthoffset),magicword),0xFFF)
  290.  
  291. ivs=bit.bxor(memory.readdwordunsigned(start+32+miscoffset+4),magicword)
  292.  
  293. hpiv=bit.band(ivs,0x1F)
  294. atkiv=bit.band(ivs,0x1F*0x20)/0x20
  295. defiv=bit.band(ivs,0x1F*0x400)/0x400
  296. spdiv=bit.band(ivs,0x1F*0x8000)/0x8000
  297. spatkiv=bit.band(ivs,0x1F*0x100000)/0x100000
  298. spdefiv=bit.band(ivs,0x1F*0x2000000)/0x2000000
  299.  
  300. nature=personality%25
  301. natinc=math.floor(nature/5)
  302. natdec=nature%5
  303.  
  304. hidpowtype=math.floor(((hpiv%2 + 2*(atkiv%2) + 4*(defiv%2) + 8*(spdiv%2) + 16*(spatkiv%2) + 32*(spdefiv%2))*15)/63)
  305. hidpowbase=math.floor(((bit.band(hpiv,2)/2 + bit.band(atkiv,2) + 2*bit.band(defiv,2) + 4*bit.band(spdiv,2) + 8*bit.band(spatkiv,2) + 16*bit.band(spdefiv,2))*40)/63 + 30)
  306.  
  307.  
  308. gui.text(90,10,string.format("HP IV=%d H%d/%d", hpiv, memory.readword(0x56 + start), memory.readword(0x58 + start)), "yellow")
  309. gui.text(90,17,string.format("Atk IV=%d A%d", atkiv, memory.readword(0x5A + start)), "red")
  310. gui.text(90,24,string.format("Def IV=%d B%d", defiv, memory.readword(0x5C + start)), "blue")
  311. gui.text(160,10,string.format("Spd IV=%d S%d",spdiv, memory.readword(0x5E + start)), "green")
  312. gui.text(160,17,string.format("SpAtk IV=%d C%d",spatkiv, memory.readword(0x60 + start)), "red")
  313. gui.text(160,24,string.format("SpDef IV=%d D%d",spdefiv, memory.readword(0x62 + start)), "blue")
  314.  
  315. gui.text(90,35,"Species "..species)
  316. gui.text(90,45,"Nature: "..naturename[nature+1])
  317. gui.text(90,55,natureorder[natinc+1].."+ "..natureorder[natdec+1].."-")
  318. gui.text(90,65,"Hidden Power: "..typeorder[hidpowtype+1].." "..hidpowbase)
  319.  
  320. end
  321.  
  322. function button1()
  323. local text
  324. local tekinumber = math.floor(memory.readbyte(0x02000073) / 16) + 1
  325. local mikatanumber = math.floor(memory.readbyte(0x02000070) / 16) + 1
  326. local inp = input.get()
  327. if (29 < inp.xmouse and 88 > inp.xmouse and 0 < inp.ymouse and 9 > inp.ymouse) then
  328. a = 192
  329. if inp.leftclick then
  330. start=0x02023F38 + 0x54 + ((tekinumber - 1) * 0x64)
  331. enemykotaiti()
  332. text = "enemykotaiti"
  333. elseif inp.rightclick then
  334. start = 0x02024190 + 0x54+ ((mikatanumber - 1) * 0x64)
  335. enemykotaiti()
  336. text = "mikatakotai"
  337. else
  338. text = "kotaitihyouji?"
  339. end
  340. else
  341. text = "kotaitihyouji?"
  342. end
  343. gui.box(29,0,88,9,64,64,255)
  344. gui.text(32,1,text)
  345. end
  346.  
  347.  
  348. function button2()
  349. local text2
  350. local inp = input.get()
  351. if (99 < inp.xmouse and 158 > inp.xmouse and 0 < inp.ymouse and 9 > inp.ymouse) then
  352. a = 192
  353. if inp.leftclick then
  354. damagekeisan()
  355. text = "damage"
  356. elseif inp.rightclick then
  357. kotaiseisei()
  358. text = "kotaiseisei"
  359. else
  360. text = "kotai/damage"
  361. end
  362. else
  363. text = "kotai/damage"
  364. end
  365. gui.box(99,0,158,9,64,64,255)
  366. gui.text(102,1,text)
  367. end
  368.  
  369.  
  370. while true do
  371. ransuuhyouji()
  372. button1()
  373. button2()
  374. emu.frameadvance()
  375. end
Advertisement
Add Comment
Please, Sign In to add comment