Advertisement
Bond697

emerald fixed frame counter

Jun 3rd, 2013
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.12 KB | None | 0 0
  1. local natureorder={"Atk","Def","Spd","SpAtk","SpDef"}
  2. local naturename={
  3.  "Hardy","Lonely","Brave","Adamant","Naughty",
  4.  "Bold","Docile","Relaxed","Impish","Lax",
  5.  "Timid","Hasty","Serious","Jolly","Naive",
  6.  "Modest","Mild","Quiet","Bashful","Rash",
  7.  "Calm","Gentle","Sassy","Careful","Quirky"}
  8. local typeorder={
  9.  "Fighting","Flying","Poison","Ground",
  10.  "Rock","Bug","Ghost","Steel",
  11.  "Fire","Water","Grass","Electric",
  12.  "Psychic","Ice","Dragon","Dark"}
  13.  
  14. local start=0x02024744
  15. local personality
  16. local trainerid
  17. local magicword
  18. local growthoffset
  19. local miscoffset
  20. local i
  21. local rngframe=0x020249C0
  22.  
  23. local species
  24. local ivs
  25. local hpiv
  26. local atkiv
  27. local defiv
  28. local spdiv
  29. local spatkiv
  30. local spdefiv
  31. local nature
  32. local natinc
  33. local natdec
  34. local hidpowbase
  35. local hidpowtype
  36.  
  37. while true do
  38.  
  39.  personality=memory.readdwordunsigned(start)
  40.  trainerid=memory.readdwordunsigned(start+4)
  41.  magicword=bit.bxor(personality, trainerid)
  42.  seed=memory.readdwordunsigned(0x03005D80)
  43.  
  44.  i=personality%24
  45.  
  46.  if i<=5 then
  47.   growthoffset=0
  48.  elseif i%6<=1 then
  49.   growthoffset=12
  50.  elseif i%2==0 then
  51.   growthoffset=24
  52.  else
  53.   growthoffset=36
  54.  end
  55.  
  56.  if i>=18 then
  57.   miscoffset=0
  58.  elseif i%6>=4 then
  59.   miscoffset=12
  60.  elseif i%2==1 then
  61.   miscoffset=24
  62.  else
  63.   miscoffset=36
  64.  end
  65.  
  66.  species=bit.band(bit.bxor(memory.readdwordunsigned(start+32+growthoffset),magicword),0xFFF)
  67.  
  68.  ivs=bit.bxor(memory.readdwordunsigned(start+32+miscoffset+4),magicword)
  69.  
  70.  hpiv=bit.band(ivs,0x1F)
  71.  atkiv=bit.band(ivs,0x1F*0x20)/0x20
  72.  defiv=bit.band(ivs,0x1F*0x400)/0x400
  73.  spdiv=bit.band(ivs,0x1F*0x8000)/0x8000
  74.  spatkiv=bit.band(ivs,0x1F*0x100000)/0x100000
  75.  spdefiv=bit.band(ivs,0x1F*0x2000000)/0x2000000
  76.  
  77.  nature=personality%25
  78.  natinc=math.floor(nature/5)
  79.  natdec=nature%5
  80.  
  81.  hidpowtype=math.floor(((hpiv%2 + 2*(atkiv%2) + 4*(defiv%2) + 8*(spdiv%2) + 16*(spatkiv%2) + 32*(spdefiv%2))*15)/63)
  82.  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)
  83.  
  84.  gui.text(0,0,"Stats")
  85.  gui.text(30,0,"HP  "..memory.readwordunsigned(start+86))
  86.  gui.text(65,0,"Atk "..memory.readwordunsigned(start+90))
  87.  gui.text(99,0,"Def "..memory.readwordunsigned(start+92))
  88.  gui.text(133,0,"SpA "..memory.readwordunsigned(start+96))
  89.  gui.text(167,0,"SpD "..memory.readwordunsigned(start+98))
  90.  gui.text(201,0,"Spe "..memory.readwordunsigned(start+94))
  91.  
  92.  gui.text(0,8,"IVs")
  93.  gui.text(30,8,"HP  "..hpiv)
  94.  gui.text(65,8,"Atk "..atkiv)
  95.  gui.text(99,8,"Def "..defiv)
  96.  gui.text(133,8,"SpA "..spatkiv)
  97.  gui.text(167,8,"SpD "..spdefiv)
  98.  gui.text(201,8,"Spe "..spdiv)
  99.  
  100.  gui.text(0,40,"PID:  "..string.format("%08X", personality))
  101.  gui.text(60,40,"IVs: "..string.format("%08X", ivs))
  102.  gui.text(0,50,"Nature: "..naturename[nature+1])
  103.  gui.text(0,60,natureorder[natinc+1].."+ "..natureorder[natdec+1].."-")
  104.  gui.text(167,15,"HP "..typeorder[hidpowtype+1].." "..hidpowbase)
  105.  gui.text(0,95,"Frame "..memory.readdwordunsigned(rngframe))
  106.  gui.text(0,105,"Seed: "..string.format("%8X", seed))
  107.  print("Seed: "..string.format("%8X", seed))
  108.  
  109.  emu.frameadvance()
  110.  
  111. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement