Page 1 of 2 12 LastLast
Results 1 to 15 of 27

Thread: Gen 3 Lua Scripts

  1. #1

    Gen 3 Lua Scripts

    FractalFusion did some great work in regards to gen 3 TAS, and I stumbled upon some of his Lua scripts and wanted to improve upon them for RNG abuse.

    The following scripts work for R/S, you have to change the memory offset in the script if you are on FRLG/E
    Party PKM #1 PID/IV Display


    Spoiler

    Code:
    -- http://tasvideos.org/forum/viewtopic.php?t=4101
    -- http://tasvideos.org/forum/viewtopic.php?t=4101&postdays=0&postorder=asc&start=100 my post
    -- http://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_data_structure_in_Generation_III
    -- ruby/sapphire 0x03004360
    -- emerald 0x02024190 J 0x020244EC U
    -- firered 0x02024284
    -- leafgreen 0x020241e4
    
    -- 64
    -- 4360 43C4 4428 448C 44F0 4554
    -- 45C0 4624
    
    local natureorder={"Atk","Def","Spd","SpAtk","SpDef"}
    local naturename={
     "Hardy","Lonely","Brave","Adamant","Naughty",
     "Bold","Docile","Relaxed","Impish","Lax",
     "Timid","Hasty","Serious","Jolly","Naive",
     "Modest","Mild","Quiet","Bashful","Rash",
     "Calm","Gentle","Sassy","Careful","Quirky"}
    
    local start=0x03004360
    local personality
    local trainerid
    local magicword
    local growthoffset
    local miscoffset
    local i
    
    local species
    local ivs
    local hpiv
    local atkiv
    local defiv
    local spdiv
    local spatkiv
    local spdefiv
    local nature
    local natinc
    local natdec
    
    while true do
    
     personality=memory.readdwordunsigned(start)
     trainerid=memory.readdwordunsigned(start+4)
     magicword=bit.bxor(personality, trainerid)
     
     i=personality%24
     
     if i<=5 then
      growthoffset=0
     elseif i%6<=1 then
      growthoffset=12
     elseif i%2==0 then
      growthoffset=24
     else
      growthoffset=36
     end
    
     if i>=18 then
      miscoffset=0
     elseif i%6>=4 then
      miscoffset=12
     elseif i%2==1 then
      miscoffset=24
     else
      miscoffset=36
     end
    
     species=bit.band(bit.bxor(memory.readdwordunsigned(start+32+growthoffset),magicword),0xFFF)
    
     ivs=bit.bxor(memory.readdwordunsigned(start+32+miscoffset+4),magicword)
     
     hpiv=bit.band(ivs,0x1F)
     atkiv=bit.band(ivs,0x1F*0x20)/0x20
     defiv=bit.band(ivs,0x1F*0x400)/0x400
     spdiv=bit.band(ivs,0x1F*0x8000)/0x8000
     spatkiv=bit.band(ivs,0x1F*0x100000)/0x100000
     spdefiv=bit.band(ivs,0x1F*0x2000000)/0x2000000
     
     nature=personality%25
     natinc=math.floor(nature/5)
     natdec=nature%5
     
    
     gui.text(0,0,"HP IV="..hpiv, "yellow")
     gui.text(0,10,"Atk IV="..atkiv, "red")
     gui.text(50,10,"Def IV="..defiv, "orange")
     gui.text(50,0,"Spd IV="..spdiv, "green")
     gui.text(0,20,"SpAtk IV="..spatkiv, "red")
     gui.text(50,20,"SpDef IV="..spdefiv, "orange")
    
     gui.text(0,30,"Species "..species)
     gui.text(0,40,"Nature: "..naturename[nature+1])
     gui.text(0,50,natureorder[natinc+1].."+ "..natureorder[natdec+1].."-")
     gui.text(0,60,"PID: "..string.format("%08X", personality))
    
    
     emu.frameadvance()
    
    end


    vvvvvvvvvvvvvvvvvvv
    Last edited by Kaphotics; Aug 6th, 2011 at 12:55 AM.

  2. #2
    Super Moderator Translation ContributorDeveloperGame Save ResearcherROM ResearcherRAM ResearcherIRC AOPEvent ContributorSuper Moderator
    Join Date
    May 2010
    Location
    pc + 8
    Age
    30
    Posts
    1,158

    Re: Gen 3 Lua Scripts

    http://pastebin.com/ZHxPYDsN

    http://tasvideos.org/forum/viewtopic...=asc&start=200


    considering these scripts are 99.9% fractalfusion's, there's no reason not to link to his stuff.

  3. #3

    Re: Gen 3 Lua Scripts

    Code:
    -- 64
    -- 4360 43C4 4428 448C 44F0 4554
    -- 45C0 4624
    64 between each pkm in RAM
    RS Party Pokemon Offsets
    RS Enemy Pokemon offsets (single / double)
    Last edited by Kaphotics; Aug 6th, 2011 at 12:56 AM.

  4. #4

    Re: Gen 3 Lua Scripts

    the script only run on R/S?, 'cuz i try on LG & E and it doesn't work

  5. #5

    Re: Gen 3 Lua Scripts

    You have to change the offsets to the memory locations for the version you want.

  6. #6

    Re: Gen 3 Lua Scripts

    the offsets:
    ruby/sapphire 0x03004360
    emerald 0x02024190 J 0x020244EC U
    firered 0x02024284
    leafgreen 0x020241e4
    are the same for Wild Pokemon?

  7. #7

    Re: Gen 3 Lua Scripts

    No those are for party Pokemon, not for the wild Pokemon. Someone would have to find those locations for the other games.

    =0x030045C0 is for R/S.

    see below, I found the offsets and edited the lua to make each one work on all english games.
    Last edited by Kaphotics; Aug 6th, 2011 at 12:56 AM.

  8. #8

    Re: Gen 3 Lua Scripts

    R/S RNG Suite:



    Download
    Spoiler
    Code:
    local natureorder={"Atk","Def","Spd","SpAtk","SpDef"}
    local naturename={
     "Hardy","Lonely","Brave","Adamant","Naughty",
     "Bold","Docile","Relaxed","Impish","Lax",
     "Timid","Hasty","Serious","Jolly","Naive",
     "Modest","Mild","Quiet","Bashful","Rash",
     "Calm","Gentle","Sassy","Careful","Quirky"}
    local typeorder={
     "Fighting","Flying","Poison","Ground",
     "Rock","Bug","Ghost","Steel",
     "Fire","Water","Grass","Electric",
     "Psychic","Ice","Dragon","Dark"}
    
    local start=0x030045C0
    local personality
    local trainerid
    local magicword
    local growthoffset
    local miscoffset
    local i
    
    local species
    local ivs
    local hpiv
    local atkiv
    local defiv
    local spdiv
    local spatkiv
    local spdefiv
    local nature
    local natinc
    local natdec
    local hidpowbase
    local hidpowtype
    
    while true do
    
     personality=memory.readdwordunsigned(start)
     trainerid=memory.readdwordunsigned(start+4)
     magicword=bit.bxor(personality, trainerid)
     seed=memory.readdwordunsigned(0x03004818)
     
     i=personality%24
     
     if i<=5 then
      growthoffset=0
     elseif i%6<=1 then
      growthoffset=12
     elseif i%2==0 then
      growthoffset=24
     else
      growthoffset=36
     end
    
     if i>=18 then
      miscoffset=0
     elseif i%6>=4 then
      miscoffset=12
     elseif i%2==1 then
      miscoffset=24
     else
      miscoffset=36
     end
    
     species=bit.band(bit.bxor(memory.readdwordunsigned(start+32+growthoffset),magicword),0xFFF)
    
     ivs=bit.bxor(memory.readdwordunsigned(start+32+miscoffset+4),magicword)
     
     hpiv=bit.band(ivs,0x1F)
     atkiv=bit.band(ivs,0x1F*0x20)/0x20
     defiv=bit.band(ivs,0x1F*0x400)/0x400
     spdiv=bit.band(ivs,0x1F*0x8000)/0x8000
     spatkiv=bit.band(ivs,0x1F*0x100000)/0x100000
     spdefiv=bit.band(ivs,0x1F*0x2000000)/0x2000000
     
     nature=personality%25
     natinc=math.floor(nature/5)
     natdec=nature%5
     
     hidpowtype=math.floor(((hpiv%2 + 2*(atkiv%2) + 4*(defiv%2) + 8*(spdiv%2) + 16*(spatkiv%2) + 32*(spdefiv%2))*15)/63)
     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)
     
     gui.text(0,0,"Stats")
     gui.text(30,0,"HP  "..memory.readwordunsigned(start+86))
     gui.text(65,0,"Atk "..memory.readwordunsigned(start+90))
     gui.text(99,0,"Def "..memory.readwordunsigned(start+92))
     gui.text(133,0,"SpA "..memory.readwordunsigned(start+96))
     gui.text(167,0,"SpD "..memory.readwordunsigned(start+98))
     gui.text(201,0,"Spe "..memory.readwordunsigned(start+94))
    
     gui.text(0,8,"IVs")
     gui.text(30,8,"HP  "..hpiv)
     gui.text(65,8,"Atk "..atkiv)
     gui.text(99,8,"Def "..defiv)
     gui.text(133,8,"SpA "..spatkiv)
     gui.text(167,8,"SpD "..spdefiv)
     gui.text(201,8,"Spe "..spdiv)
    
     gui.text(0,40,"PID:  "..string.format("%08X", personality))
     gui.text(60,40,"IVs: "..string.format("%08X", ivs))
     gui.text(0,50,"Nature: "..naturename[nature+1])
     gui.text(0,60,natureorder[natinc+1].."+ "..natureorder[natdec+1].."-")
     gui.text(167,15,"HP "..typeorder[hidpowtype+1].." "..hidpowbase)
     gui.text(0,95,vba.framecount()) 
     gui.text(0,105,"Seed: "..string.format("%8X", seed))
     print("Seed: "..string.format("%8X", seed))
    
     emu.frameadvance()
    
    end

    FRLG RNG Suite:



    Download
    Spoiler
    Code:
    local natureorder={"Atk","Def","Spd","SpAtk","SpDef"}
    local naturename={
     "Hardy","Lonely","Brave","Adamant","Naughty",
     "Bold","Docile","Relaxed","Impish","Lax",
     "Timid","Hasty","Serious","Jolly","Naive",
     "Modest","Mild","Quiet","Bashful","Rash",
     "Calm","Gentle","Sassy","Careful","Quirky"}
    local typeorder={
     "Fighting","Flying","Poison","Ground",
     "Rock","Bug","Ghost","Steel",
     "Fire","Water","Grass","Electric",
     "Psychic","Ice","Dragon","Dark"}
    
    local start=0x0202402C
    local personality
    local trainerid
    local magicword
    local growthoffset
    local miscoffset
    local i
    
    local species
    local ivs
    local hpiv
    local atkiv
    local defiv
    local spdiv
    local spatkiv
    local spdefiv
    local nature
    local natinc
    local natdec
    local hidpowbase
    local hidpowtype
    
    while true do
    
     personality=memory.readdwordunsigned(start)
     trainerid=memory.readdwordunsigned(start+4)
     magicword=bit.bxor(personality, trainerid)
     seed=memory.readdwordunsigned(0x03005000)
     
     i=personality%24
     
     if i<=5 then
      growthoffset=0
     elseif i%6<=1 then
      growthoffset=12
     elseif i%2==0 then
      growthoffset=24
     else
      growthoffset=36
     end
    
     if i>=18 then
      miscoffset=0
     elseif i%6>=4 then
      miscoffset=12
     elseif i%2==1 then
      miscoffset=24
     else
      miscoffset=36
     end
    
     species=bit.band(bit.bxor(memory.readdwordunsigned(start+32+growthoffset),magicword),0xFFF)
    
     ivs=bit.bxor(memory.readdwordunsigned(start+32+miscoffset+4),magicword)
     
     hpiv=bit.band(ivs,0x1F)
     atkiv=bit.band(ivs,0x1F*0x20)/0x20
     defiv=bit.band(ivs,0x1F*0x400)/0x400
     spdiv=bit.band(ivs,0x1F*0x8000)/0x8000
     spatkiv=bit.band(ivs,0x1F*0x100000)/0x100000
     spdefiv=bit.band(ivs,0x1F*0x2000000)/0x2000000
     
     nature=personality%25
     natinc=math.floor(nature/5)
     natdec=nature%5
     
     hidpowtype=math.floor(((hpiv%2 + 2*(atkiv%2) + 4*(defiv%2) + 8*(spdiv%2) + 16*(spatkiv%2) + 32*(spdefiv%2))*15)/63)
     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)
     
     gui.text(0,0,"Stats")
     gui.text(30,0,"HP  "..memory.readwordunsigned(start+86))
     gui.text(65,0,"Atk "..memory.readwordunsigned(start+90))
     gui.text(99,0,"Def "..memory.readwordunsigned(start+92))
     gui.text(133,0,"SpA "..memory.readwordunsigned(start+96))
     gui.text(167,0,"SpD "..memory.readwordunsigned(start+98))
     gui.text(201,0,"Spe "..memory.readwordunsigned(start+94))
    
     gui.text(0,8,"IVs")
     gui.text(30,8,"HP  "..hpiv)
     gui.text(65,8,"Atk "..atkiv)
     gui.text(99,8,"Def "..defiv)
     gui.text(133,8,"SpA "..spatkiv)
     gui.text(167,8,"SpD "..spdefiv)
     gui.text(201,8,"Spe "..spdiv)
    
     gui.text(0,40,"PID:  "..string.format("%08X", personality))
     gui.text(60,40,"IVs: "..string.format("%08X", ivs))
     gui.text(0,50,"Nature: "..naturename[nature+1])
     gui.text(0,60,natureorder[natinc+1].."+ "..natureorder[natdec+1].."-")
     gui.text(167,15,"HP "..typeorder[hidpowtype+1].." "..hidpowbase)
     gui.text(0,95,vba.framecount()) 
     gui.text(0,105,"Seed: "..string.format("%8X", seed))
     print("Seed: "..string.format("%8X", seed))
    
     emu.frameadvance()
    
    end

    Emerald RNG Suite:



    Download
    Spoiler
    Code:
    local natureorder={"Atk","Def","Spd","SpAtk","SpDef"}
    local naturename={
     "Hardy","Lonely","Brave","Adamant","Naughty",
     "Bold","Docile","Relaxed","Impish","Lax",
     "Timid","Hasty","Serious","Jolly","Naive",
     "Modest","Mild","Quiet","Bashful","Rash",
     "Calm","Gentle","Sassy","Careful","Quirky"}
    local typeorder={
     "Fighting","Flying","Poison","Ground",
     "Rock","Bug","Ghost","Steel",
     "Fire","Water","Grass","Electric",
     "Psychic","Ice","Dragon","Dark"}
    
    local start=0x02024744
    local personality
    local trainerid
    local magicword
    local growthoffset
    local miscoffset
    local i
    
    local species
    local ivs
    local hpiv
    local atkiv
    local defiv
    local spdiv
    local spatkiv
    local spdefiv
    local nature
    local natinc
    local natdec
    local hidpowbase
    local hidpowtype
    
    while true do
    
     personality=memory.readdwordunsigned(start)
     trainerid=memory.readdwordunsigned(start+4)
     magicword=bit.bxor(personality, trainerid)
     seed=memory.readdwordunsigned(0x03005D80)
     
     i=personality%24
     
     if i<=5 then
      growthoffset=0
     elseif i%6<=1 then
      growthoffset=12
     elseif i%2==0 then
      growthoffset=24
     else
      growthoffset=36
     end
    
     if i>=18 then
      miscoffset=0
     elseif i%6>=4 then
      miscoffset=12
     elseif i%2==1 then
      miscoffset=24
     else
      miscoffset=36
     end
    
     species=bit.band(bit.bxor(memory.readdwordunsigned(start+32+growthoffset),magicword),0xFFF)
    
     ivs=bit.bxor(memory.readdwordunsigned(start+32+miscoffset+4),magicword)
     
     hpiv=bit.band(ivs,0x1F)
     atkiv=bit.band(ivs,0x1F*0x20)/0x20
     defiv=bit.band(ivs,0x1F*0x400)/0x400
     spdiv=bit.band(ivs,0x1F*0x8000)/0x8000
     spatkiv=bit.band(ivs,0x1F*0x100000)/0x100000
     spdefiv=bit.band(ivs,0x1F*0x2000000)/0x2000000
     
     nature=personality%25
     natinc=math.floor(nature/5)
     natdec=nature%5
     
     hidpowtype=math.floor(((hpiv%2 + 2*(atkiv%2) + 4*(defiv%2) + 8*(spdiv%2) + 16*(spatkiv%2) + 32*(spdefiv%2))*15)/63)
     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)
     
     gui.text(0,0,"Stats")
     gui.text(30,0,"HP  "..memory.readwordunsigned(start+86))
     gui.text(65,0,"Atk "..memory.readwordunsigned(start+90))
     gui.text(99,0,"Def "..memory.readwordunsigned(start+92))
     gui.text(133,0,"SpA "..memory.readwordunsigned(start+96))
     gui.text(167,0,"SpD "..memory.readwordunsigned(start+98))
     gui.text(201,0,"Spe "..memory.readwordunsigned(start+94))
    
     gui.text(0,8,"IVs")
     gui.text(30,8,"HP  "..hpiv)
     gui.text(65,8,"Atk "..atkiv)
     gui.text(99,8,"Def "..defiv)
     gui.text(133,8,"SpA "..spatkiv)
     gui.text(167,8,"SpD "..spdefiv)
     gui.text(201,8,"Spe "..spdiv)
    
     gui.text(0,40,"PID:  "..string.format("%08X", personality))
     gui.text(60,40,"IVs: "..string.format("%08X", ivs))
     gui.text(0,50,"Nature: "..naturename[nature+1])
     gui.text(0,60,natureorder[natinc+1].."+ "..natureorder[natdec+1].."-")
     gui.text(167,15,"HP "..typeorder[hidpowtype+1].." "..hidpowbase)
     gui.text(0,95,vba.framecount()) 
     gui.text(0,105,"Seed: "..string.format("%8X", seed))
     print("Seed: "..string.format("%8X", seed))
    
     emu.frameadvance()
    
    end

  9. #9

    Re: Gen 3 Lua Scripts

    I believe this works on Emerald (J):
    Code:
    local natureorder={"Atk","Def","Spd","SpAtk","SpDef"}
    local naturename={
     "Hardy","Lonely","Brave","Adamant","Naughty",
     "Bold","Docile","Relaxed","Impish","Lax",
     "Timid","Hasty","Serious","Jolly","Naive",
     "Modest","Mild","Quiet","Bashful","Rash",
     "Calm","Gentle","Sassy","Careful","Quirky"}
    local typeorder={
     "Fighting","Flying","Poison","Ground",
     "Rock","Bug","Ghost","Steel",
     "Fire","Water","Grass","Electric",
     "Psychic","Ice","Dragon","Dark"}
    
    local start=0x020243E8
    local personality
    local trainerid
    local magicword
    local growthoffset
    local miscoffset
    local i
    
    local species
    local ivs
    local hpiv
    local atkiv
    local defiv
    local spdiv
    local spatkiv
    local spdefiv
    local nature
    local natinc
    local natdec
    local hidpowbase
    local hidpowtype
    
    while true do
    
     personality=memory.readdwordunsigned(start)
     trainerid=memory.readdwordunsigned(start+4)
     magicword=bit.bxor(personality, trainerid)
     seed=memory.readdwordunsigned(0x03005AE0)
     
     i=personality%24
     
     if i<=5 then
      growthoffset=0
     elseif i%6<=1 then
      growthoffset=12
     elseif i%2==0 then
      growthoffset=24
     else
      growthoffset=36
     end
    
     if i>=18 then
      miscoffset=0
     elseif i%6>=4 then
      miscoffset=12
     elseif i%2==1 then
      miscoffset=24
     else
      miscoffset=36
     end
    
     species=bit.band(bit.bxor(memory.readdwordunsigned(start+32+growthoffset),magicword),0xFFF)
    
     ivs=bit.bxor(memory.readdwordunsigned(start+32+miscoffset+4),magicword)
     
     hpiv=bit.band(ivs,0x1F)
     atkiv=bit.band(ivs,0x1F*0x20)/0x20
     defiv=bit.band(ivs,0x1F*0x400)/0x400
     spdiv=bit.band(ivs,0x1F*0x8000)/0x8000
     spatkiv=bit.band(ivs,0x1F*0x100000)/0x100000
     spdefiv=bit.band(ivs,0x1F*0x2000000)/0x2000000
     
     nature=personality%25
     natinc=math.floor(nature/5)
     natdec=nature%5
     
     hidpowtype=math.floor(((hpiv%2 + 2*(atkiv%2) + 4*(defiv%2) + 8*(spdiv%2) + 16*(spatkiv%2) + 32*(spdefiv%2))*15)/63)
     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)
     
     gui.text(0,0,"Stats")
     gui.text(30,0,"HP  "..memory.readwordunsigned(start+86))
     gui.text(65,0,"Atk "..memory.readwordunsigned(start+90))
     gui.text(99,0,"Def "..memory.readwordunsigned(start+92))
     gui.text(133,0,"SpA "..memory.readwordunsigned(start+96))
     gui.text(167,0,"SpD "..memory.readwordunsigned(start+98))
     gui.text(201,0,"Spe "..memory.readwordunsigned(start+94))
    
     gui.text(0,8,"IVs")
     gui.text(30,8,"HP  "..hpiv)
     gui.text(65,8,"Atk "..atkiv)
     gui.text(99,8,"Def "..defiv)
     gui.text(133,8,"SpA "..spatkiv)
     gui.text(167,8,"SpD "..spdefiv)
     gui.text(201,8,"Spe "..spdiv)
    
     gui.text(0,40,"PID:  "..string.format("%08X", personality))
     gui.text(60,40,"IVs: "..string.format("%08X", ivs))
     gui.text(0,50,"Nature: "..naturename[nature+1])
     gui.text(0,60,natureorder[natinc+1].."+ "..natureorder[natdec+1].."-")
     gui.text(167,15,"HP "..typeorder[hidpowtype+1].." "..hidpowbase)
     gui.text(0,95,vba.framecount()) 
     gui.text(0,105,"Seed: "..string.format("%8X", seed))
     print(""..string.format("%8X", seed))
    
     emu.frameadvance()
    
    end
    The seed memory location is correct for sure but I'm not 100% sure on the enemy pokemon location. It seems to have worked so far though.

    Edit: Too lazy to upload the file atm. Copy and paste it into a .txt file and change the extension to .lua.

  10. #10

    Re: Gen 3 Lua Scripts

    The Seed is correct, but the start is wrong, although I used an other one..

  11. #11

    Re: Gen 3 Lua Scripts

    Well the start memory location seems to be correct to me as it matched exactly when I looked at a pokemon in Enciclopedia Pokemon. If the address I have is wrong why don't you share yours?

  12. #12

    Re: Gen 3 Lua Scripts

    There's multiple places it can be.

    If you don't find the right location you will probably find one that is DMA shifted.

  13. #13

    Re: Gen 3 Lua Scripts

    And here's JP Sapphire (and presumably JP Ruby)

    Code:
    local natureorder={"Atk","Def","Spd","SpAtk","SpDef"}
    local naturename={
     "Hardy","Lonely","Brave","Adamant","Naughty",
     "Bold","Docile","Relaxed","Impish","Lax",
     "Timid","Hasty","Serious","Jolly","Naive",
     "Modest","Mild","Quiet","Bashful","Rash",
     "Calm","Gentle","Sassy","Careful","Quirky"}
    local typeorder={
     "Fighting","Flying","Poison","Ground",
     "Rock","Bug","Ghost","Steel",
     "Fire","Water","Grass","Electric",
     "Psychic","Ice","Dragon","Dark"}
    
    local start=0x030044F0
    local personality
    local trainerid
    local magicword
    local growthoffset
    local miscoffset
    local i
    
    local species
    local ivs
    local hpiv
    local atkiv
    local defiv
    local spdiv
    local spatkiv
    local spdefiv
    local nature
    local natinc
    local natdec
    local hidpowbase
    local hidpowtype
    
    while true do
    
     personality=memory.readdwordunsigned(start)
     trainerid=memory.readdwordunsigned(start+4)
     magicword=bit.bxor(personality, trainerid)
     seed=memory.readdwordunsigned(0x03004748)
     
     i=personality%24
     
     if i<=5 then
      growthoffset=0
     elseif i%6<=1 then
      growthoffset=12
     elseif i%2==0 then
      growthoffset=24
     else
      growthoffset=36
     end
    
     if i>=18 then
      miscoffset=0
     elseif i%6>=4 then
      miscoffset=12
     elseif i%2==1 then
      miscoffset=24
     else
      miscoffset=36
     end
    
     species=bit.band(bit.bxor(memory.readdwordunsigned(start+32+growthoffset),magicword),0xFFF)
    
     ivs=bit.bxor(memory.readdwordunsigned(start+32+miscoffset+4),magicword)
     
     hpiv=bit.band(ivs,0x1F)
     atkiv=bit.band(ivs,0x1F*0x20)/0x20
     defiv=bit.band(ivs,0x1F*0x400)/0x400
     spdiv=bit.band(ivs,0x1F*0x8000)/0x8000
     spatkiv=bit.band(ivs,0x1F*0x100000)/0x100000
     spdefiv=bit.band(ivs,0x1F*0x2000000)/0x2000000
     
     nature=personality%25
     natinc=math.floor(nature/5)
     natdec=nature%5
     
     hidpowtype=math.floor(((hpiv%2 + 2*(atkiv%2) + 4*(defiv%2) + 8*(spdiv%2) + 16*(spatkiv%2) + 32*(spdefiv%2))*15)/63)
     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)
     
     gui.text(0,0,"Stats")
     gui.text(30,0,"HP  "..memory.readwordunsigned(start+86))
     gui.text(65,0,"Atk "..memory.readwordunsigned(start+90))
     gui.text(99,0,"Def "..memory.readwordunsigned(start+92))
     gui.text(133,0,"SpA "..memory.readwordunsigned(start+96))
     gui.text(167,0,"SpD "..memory.readwordunsigned(start+98))
     gui.text(201,0,"Spe "..memory.readwordunsigned(start+94))
    
     gui.text(0,8,"IVs")
     gui.text(30,8,"HP  "..hpiv)
     gui.text(65,8,"Atk "..atkiv)
     gui.text(99,8,"Def "..defiv)
     gui.text(133,8,"SpA "..spatkiv)
     gui.text(167,8,"SpD "..spdefiv)
     gui.text(201,8,"Spe "..spdiv)
    
     gui.text(0,40,"PID:  "..string.format("%08X", personality))
     gui.text(60,40,"IVs: "..string.format("%08X", ivs))
     gui.text(0,50,"Nature: "..naturename[nature+1])
     gui.text(0,60,natureorder[natinc+1].."+ "..natureorder[natdec+1].."-")
     gui.text(167,15,"HP "..typeorder[hidpowtype+1].." "..hidpowbase)
     gui.text(0,95,vba.framecount()) 
     gui.text(0,105,"Seed: "..string.format("%8X", seed))
     print("Seed: "..string.format("%8X", seed))
    
     emu.frameadvance()
    
    end
    Edit: I apologize for being short with you. It's just that a lot of people have been secretive about 3rd gen things for who knows how long while they only know what they know because of other people's work (ie. the guys who figured out the RNG mechanics in the first place).
    Last edited by Hozu; Sep 1st, 2011 at 04:26 PM.

  14. #14

    Re: Gen 3 Lua Scripts

    Quote Originally Posted by Hozu View Post
    Well the start memory location seems to be correct to me as it matched exactly when I looked at a pokemon in Enciclopedia Pokemon. If the address I have is wrong why don't you share yours?
    I didn't want to offend you, sorry.

    Quote Originally Posted by Kaphotics View Post
    There's multiple places it can be.

    If you don't find the right location you will probably find one that is DMA shifted.
    Thanks Kaphotics!

  15. #15

    Re: Gen 3 Lua Scripts

    This is pretty cool.

    I was thinking about something like this for 4th gen along time ago but never got around to doing it and then ended up forgetting about it completely.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •