Advertisement
CollectorTogami

Gen1NatureCheck.Lua

Mar 5th, 2017
607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.50 KB | None | 0 0
  1.  
  2.  
  3. --NatureCheck by Collector Togami
  4. --Please select what game you are playing below to handle the offsets. At this time
  5. --this program only supports ENG versions of RBY.
  6.  
  7. Yellow=0
  8. NotYellow=1
  9.  
  10. GameVersion=NotYellow
  11.  
  12. PartyStart=0x0000D178+GameVersion
  13. PartySize=0x0000D162+GameVersion
  14. WildStart=0x0000CFF0
  15.  
  16. --Checks the currently playing audio track to see if we're in a wild fight or not
  17. AmIFacingWild=0xC027
  18. WildSong=0xF0
  19.  
  20. --This offset may not be constant across other languages
  21. PartyOffset=44
  22.  
  23. StartingY=10
  24.  
  25.  
  26. --Thanks to MKDasher for this
  27. local naturename={
  28.  "Hardy","Lonely","Brave","Adamant","Naughty",
  29.  "Bold","Docile","Relaxed","Impish","Lax",
  30.  "Timid","Hasty","Serious","Jolly","Naive",
  31.  "Modest","Mild","Quiet","Bashful","Rash",
  32.  "Calm","Gentle","Sassy","Careful","Quirky"}
  33.  
  34.  
  35. while true do
  36.  
  37.   counter=1
  38.   currentParty=PartyStart
  39.   currentY=StartingY
  40.   party=memory.readbyte(PartySize)
  41.  
  42.  
  43.  
  44.  
  45.   while party > -1 do
  46.      GoalHit=false
  47.      
  48.      --After the entire party has been read, check the opposing pokemon
  49.      if party == 0 then
  50.        currentParty=WildStart
  51.      end
  52.      
  53.    
  54.     --Not the best way to get exp but it will do for now
  55.     natureNum = memory.readbyte(currentParty)*0x10000
  56.     natureNum = natureNum + memory.readbyte(currentParty+1)*0x100
  57.     natureNum = natureNum + memory.readbyte(currentParty+2)
  58.    
  59.     natureNum = natureNum % 25
  60.    
  61.    
  62.      DeFactoIVs=memory.readwordunsigned(currentParty+13)
  63.  
  64.  
  65. if DeFactoIVs == 0xAAA2 then GoalHit = true
  66.   elseif DeFactoIVs == 0xAAA3 then GoalHit = true
  67.   elseif DeFactoIVs == 0xAAA6 then GoalHit = true
  68.   elseif DeFactoIVs == 0xAAA7 then GoalHit = true
  69.   elseif DeFactoIVs == 0xAAAA then GoalHit = true
  70.   elseif DeFactoIVs == 0xAAAB then GoalHit = true
  71.   elseif DeFactoIVs == 0xAAAE then GoalHit = true
  72. elseif DeFactoIVs == 0xAAAF then GoalHit = true
  73. end
  74.  
  75. if GoalHit == true then isShiny=" SHINY"
  76. elseif GoalHit == false then isShiny=""
  77. end
  78.    
  79.      if counter > memory.readbyte(PartySize) then
  80.        if memory.readbyte(AmIFacingWild) == WildSong then
  81.               gui.text(5,currentY,"W" ..". "..naturename[natureNum+1]..isShiny)
  82.             end
  83.            
  84.      end
  85.      
  86.  
  87.  
  88.    
  89.     if counter <= memory.readbyte(PartySize) then
  90.      gui.text(5,currentY, counter ..". "..naturename[natureNum+1]..isShiny)
  91.    end
  92.    
  93.    
  94.  
  95.     party = party - 1
  96.     counter = counter + 1
  97.     currentParty=currentParty+PartyOffset
  98.     currentY=currentY+10
  99.     end
  100.   emu.frameadvance()
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement