Page 2 of 2 FirstFirst 12
Results 16 to 27 of 27

Thread: Gen 3 Lua Scripts

  1. #16

    Re: Gen 3 Lua Scripts

    Bond697 made this fix a while ago for the Emerald script but it wasn't posted here so... This uses the game's RNG advancement counter rather than the video frame for Emerald (NA version) for consistency.

    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 rngframe=0x020249C0
    
    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,"Frame "..memory.readdwordunsigned(rngframe)) 
     gui.text(0,105,"Seed: "..string.format("%8X", seed))
     --print("Seed: "..string.format("%8X", seed))
    
     emu.frameadvance()
    
    end

  2. #17

    Re: Gen 3 Lua Scripts

    Have such scripts been made for the JP versions of FRLG? The seed address perhaps?

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

    Re: Gen 3 Lua Scripts

    3005040

  4. #19

    Re: Gen 3 Lua Scripts

    Pokemon Emerald (U)

    Emerald Egg Tracking RNG Suite

    Code:
    local rng
    local timer
    local offset 
    local pidpointer=0x0203BC78
    local pidoffset
    local pid
    local iter=0
    local base=0
    local a
    local timerseed=0
    local stepcounter
    local nature
    local ids
    local tid
    local sid
    local lpid
    local hpid
    local shiny
    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"}
    
    while true do 	
    
    	a=memory.readdwordunsigned(0x03005D84)
    	rng = memory.readwordunsigned(0x020249C0)
    	timer = memory.readwordunsigned(0x030022E4)
    	offset = math.floor(rng - timer)
    	pidoffset = math.floor(memory.readdwordunsigned(pidpointer) + 0x988)
    	pid = memory.readdwordunsigned(pidoffset)
    	nature = math.floor(pid % 0x19)
    	stepcounter = memory.readbyteunsigned(math.floor(pidoffset - 0x4,2))
    	ids = memory.readdwordunsigned(0x020244F0)
    	sid = math.floor(ids / 65536)
    	tid = ids % 0x10000
    	hpid = math.floor(pid / 65536)
    	lpid = pid % 0x10000
    	shiny = bit.bxor(bit.bxor(sid,tid),bit.bxor(lpid,hpid))
    
    	gui.text(199,140, string.format("TID: %d", tid))
    	gui.text(199,150,string.format("SID: %d", sid))
    	gui.text(1,1, string.format("RNG Information:"))
    	gui.text(1, 10, string.format("RNG Frame   -  %d", memory.readword(0x020249C0))) 
    	gui.text(1, 19, string.format("Timer Value -  %d", memory.readword(0x030022E4)))
    	gui.text(1, 28, string.format("Difference  -  %d", offset))
    	gui.text(1, 46, string.format("tRNG %08X", memory.readdwordunsigned(0x03005D84)))
    	gui.text(1, 55, string.format("pRNG %08X", memory.readdwordunsigned(0x03005D80)))
    
    	if a == 0 then 
    		base = offset
    		iter = 0 
    	elseif a > 0 then 
    		if base == base and iter < 1 then
    			iter = math.floor(offset - base - 5) 
    		else 
    			base = offset
    		end
    	end
    	
    	if a == 0 then
    		if pid == 0 then
    			gui.text(1, 73, string.format("No Egg."))
    		else
    			gui.text(1, 73, string.format("PID %08X", pid))
    			gui.text(1, 82,"Nature: "..naturename[nature+1])
    		end
    
    	elseif a < 65536 then
    		gui.text(1, 73, string.format("Egg Generating... please advance another frame!"))
    		gui.text(1, 82, string.format("tRNG seeded, no temporary PID testing yet..."))
    
    	elseif math.floor(memory.readdwordunsigned(0x03007D98)/65536) == math.floor(a/65536) then
    		gui.text(1, 73, string.format("Egg Generating... please advance another frame!"))
    		gui.text(1, 82, string.format("TempPID %08X", memory.readdwordunsigned(0x03007D98)))
    
    	else
    		gui.text(1, 73, string.format("PID %08X", pid))
    --		gui.text(1, 91, string.format("loc %08X", pidoffset))
    
     		gui.text(1, 82,"Nature: "..naturename[nature+1])
    		if shiny < 8 then
    			gui.text(1, 64, string.format("SHINY!!!"))
    		end 
    
    		if iter > 1 then
    			gui.text(1, 110, string.format("stone worked!"))
    			gui.text(1, 100, string.format("approx iter: %d", iter))
    		else
    			gui.text(1, 110, string.format("stone failed?"))
    			gui.text(1, 100, string.format("first egg PID result"))
    		end
    	end
    
    		gui.text(1,130,string.format("Step Counter: %02X", stepcounter))
    	if pid > 0 then
    		gui.text(1,140,string.format("Egg Generated, go get it!"))
    	elseif stepcounter == 254 then
    		gui.text(1,140,string.format("Next Step might generate an egg!"))
    	elseif stepcounter == 255 then
    		gui.text(1,140,string.format("255th Step Taken."))
    	else
    		gui.text(1,140,string.format("Keep on steppin'"))
    	end
    
    	emu.frameadvance() 
    end
    fixed shiny check, fixed walking outside preservation
    Last edited by Kaphotics; May 21st, 2012 at 01:00 AM.

  5. #20

    Re: Gen 3 Lua Scripts

    Does anyong here have the memory address of the ID/SID in PKMN FR English version? I was able to use the Emerald script's part on Sapphire but with the Sapphire address for the ID/SID to display those attributes, now I would like to do the same for Fire Red. Or if possible coud one upload a script with the ability to see the ID/SID in Fire Red please?

  6. #21

    Re: Gen 3 Lua Scripts

    Pretty sure it's DMA shifted every time, but after 3 times I found it at 02024288.

    Anyways you can just use a save editor to find your ID/SID.

  7. #22

    Re: Gen 3 Lua Scripts

    Thanks Kaphotics. I just needed this because I had been RNG'ing ID/SID in Fire Red and it was frustrating having to save state and collect a starter each time to identfy if it had worked.

  8. #23

    Re: Gen 3 Lua Scripts

    PID Frame Check for Emerald



    Code:
    local pid=0xPUT THE ENTIRE HEX PID HERE
    local mf,sf,pr=math.floor,string.format,print
    local ts,f,d,cp=0,0,0,0
    
    function rand(s)
    	return (0x4e6d*(s%65536)+((0x41C6*(s%65536)+0x4e6d*mf(s/65536))%65536)*65536+0x6073)%(4294967296)
    end
    
    function main()
       while cp ~= pid do
    	ts=rand(ts)+0
    	cp=mf(rand(ts)/65536)*0x10000+mf(ts/65536)
    	f=f+1
       end
    
       if d==0 then
    	pr("PID: "..sf("%5XXXX", mf(pid/4096)))
    	pr("RNG Frame: "..sf("%d", f))
    	pr("Seconds: "..sf("%.2f", f/60))
    	if f<10000 then pr("Seems like a soft reset!") end
    	d=1 
       end
    end
    
    gui.register(main)
    checks the earliest frame that a PID can occur for emerald... just a small script to easily see if an upload is a plausible soft reset

  9. #24

    Re: Gen 3 Lua Scripts

    The script to view your Pokemon's IV stats (the one in your party) didn't work for FR/LG (yes, I swapped the offsets).

  10. #25

    Re: Gen 3 Lua Scripts

    here is the deal.. the download for the emerald lua script is down and when i try to copy/paste the code into notepad and change the .txt to .lua and then load it into the lua script in VBA, it doesnt load into the output. what am i doing wrong..

  11. #26

    Re: Gen 3 Lua Scripts

    Gen3 Hoenn Feebas Seed/Tile Finder - RSE (U) Only



    NOTE: Zip file contains the lua script and the images for tile number locations (made by Tux)

    Code:
    -- Gen3 Hoenn Feebas Seed/Tile Finder
    
    -- 0 - Pokemon Emerald (U)
    -- 1 - Pokemon Ruby/Sapphire (U)
    -- Change this depending on your game
    local game = 0
    
    local pointer
    local addend
    
    if game == 0 then
    	pointer = 0x3005D8C
    	addend = 0x2E6A
    elseif game == 1 then
    	pointer = 0x02025734
    	addend = 0x2DD6
    end
    
    
    -- Adapted from Kaphotics' RNG for LUA
    function rng(seed)
    	return (0x4E6D * (seed % 65536) +((0x41C6 * (seed % 65536 )+ 0x4E6D * math.floor(seed / 65536)) % 65536) * 65536 +0x3039) % (4294967296)
    end
    
    -- Tux - https://www.smogon.com/forums/threads/past-gen-rng-research.61090/page-34#post-3986326
    function is_feebas_tile(feebas_seed, current_tile)
    	rng_seed = feebas_seed
    	i = 0
    	tile = 0
    	while i <= 5 do
    		rng_seed = rng(rng_seed)
    		tile = (bit.rshift(rng_seed, 16)) % 0x1BF
    		if tile >= 4 then
    			i = i + 1
    		end
    		if tile == current_tile then
    			return true
    		end
    	end
    	return false
    end
    
    function print_feebas_info()
    	local feebas_pointer_address
    	local feebas_seed
    	if game == 0 then
    		feebas_pointer_address = memory.readdwordunsigned(pointer) + addend
    	elseif game == 1 then
    		feebas_pointer_address = pointer + addend
    	end
    	feebas_seed = memory.readwordunsigned(feebas_pointer_address)
    	x = 4
    	y = 3
    	gui.box(2, 2, 76, 32, "white")
    	gui.text(x, y , "Feebas Seed: "..feebas_seed, "green")
    	
    	current_tile = 0
    	ctr = 0
    	y = y + 10
    	while current_tile <= 600 do
    		if is_feebas_tile(feebas_seed, current_tile)then
    			if ctr == 3 then
    				ctr = 0
    				y = y + 10
    				x = 4
    			end
    			x = x + 15
    			ctr = ctr + 1
    		 	gui.text(x, y, current_tile, "yellow")
    		 end
    		 current_tile = current_tile + 1
    	end
    end
    gui.register(print_feebas_info)
    Attached Images Attached Images
    Attached Files Attached Files

  12. #27

    Re: Gen 3 Lua Scripts

    I play on FR (U) and .lua doesn't display starter ivs..

Page 2 of 2 FirstFirst 12

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
  •