Hey guys, I've been working with Zeromus to figure out how to script some things I needed in LUA. He also built some new versions of Bizhawk so that I could run these scripts. One of them I use to find the frame where an enemy misses me, one for finding crits and one for finding a battle that gives me the enemies I want.
local missSprite
local framesUntilMiss = {}
framesUntilMiss.melee = 491
framesUntilMiss.ranged = 173
local memDomain = "VRAM"
local startFrame = emu.framecount()
local moveFrameInput = 0
local frameToInput = startFrame + moveFrameInput
local foundEnemyMiss = false
local melee = true
emu.limitframerate(false)
function gameInfo()
if(emu.framecount() == frameToInput) then
joypad.set({["P1 A"] = true})
else
joypad.set({["P1 A"] = null})
end
memory.usememorydomain(memDomain)
missSprite = memory.read_u16_be(0x0544)
if(melee) then
gui.drawText(5,5, "Enemy Miss In: " .. (startFrame + framesUntilMiss.melee - emu.framecount()))
if emu.framecount() >= (startFrame + framesUntilMiss.melee + moveFrameInput) then
if tonumber(missSprite) == 17952 then
client.togglepause()
else
moveFrameInput = moveFrameInput + 1
frameToInput = startFrame + moveFrameInput
tastudio.setplayback(startFrame)
end
end
else
gui.drawText(5,5, "Crit in: " .. (startFrame + framesUntilMiss.ranged - emu.framecount()))
end
end
while (foundEnemyMiss ~= true) do
gameInfo()
emu.frameadvance()
end
local critSprite
local monster2HP
local monster3HP
local framesToCrit = {}
framesToCrit.melee = 75
framesToCrit.ranged = 173
local memDomain = "VRAM"
local startFrame = emu.framecount()
local moveFrameInput = 0
local frameToInput = startFrame + moveFrameInput
local foundCriticalHit = false
local melee = false
emu.limitframerate(false)
function gameInfo()
if(emu.framecount() == frameToInput) then
joypad.set({["P1 A"] = true})
else
joypad.set({["P1 A"] = null})
end
memory.usememorydomain(memDomain)
critSprite = memory.read_u16_be(0x0544)
if(melee) then
gui.drawText(5,5, "Crit in: " .. (frameToInput + framesToCrit.melee - emu.framecount()))
if emu.framecount() >= (startFrame + framesToCrit.melee + moveFrameInput) then
if tonumber(critSprite) == 13348 then
client.togglepause()
else
moveFrameInput = moveFrameInput + 1
frameToInput = startFrame + moveFrameInput
tastudio.setplayback(frameToInput-1)
end
end
else
gui.drawText(5,5, "Crit in: " .. (frameToInput + framesToCrit.ranged - emu.framecount()))
if emu.framecount() >= (startFrame + framesToCrit.ranged + moveFrameInput) then
if tonumber(critSprite) == 13348 then
foundCriticalHit = true
client.togglepause()
else
moveFrameInput = moveFrameInput + 1
frameToInput = startFrame + moveFrameInput
tastudio.setplayback(frameToInput-1)
end
end
end
end
while (foundCriticalHit ~= true) do
gameInfo()
emu.frameadvance()
end
local monster1HP
local monster2HP
local monster3HP
local framesToBattle = 115
local memDomain = "WRAM"
local startFrame = emu.framecount()
local moveFrameInput = 0
local frameToInput = startFrame + moveFrameInput
local foundEncounter = false
function gameInfo()
if(emu.framecount() == frameToInput) then
joypad.set({["P1 Down"] = true, ["P1 R"] = true})
else
joypad.set({["P1 Down"] = null, ["P1 R"] = null})
end
memory.usememorydomain(memDomain)
monster1HP = memory.read_u8(0x009567)
monster2HP = memory.read_u8(0x00959C)
monster3HP = memory.read_u8(0x0095D1)
gui.drawText(5,5, "Battle in: " .. (frameToInput + framesToBattle - emu.framecount()))
if emu.framecount() >= (startFrame + framesToBattle + moveFrameInput) then
if (tonumber(monster1HP)) >= 14 and (tonumber(monster2HP)) >= 14 and (tonumber(monster3HP)) >= 14 and (tonumber(monster3HP)) ~= 91 then
if (emu.framecount() == startFrame + 115) then
while emu.framecount() ~= startFrame + 385 do
gui.drawText(5,25, "Script removing control in: " .. startFrame + 385 - emu.framecount() .. " frames")
emu.frameadvance()
end
foundEncounter = true
end
else
moveFrameInput = moveFrameInput + 1
frameToInput = startFrame + moveFrameInput
tastudio.setplayback(frameToInput-1)
end
end
end
while (foundEncounter ~= true) do
gameInfo()
emu.frameadvance()
if(foundEncounter) then client.togglepause() end
end