Working on updating
a script I found further back in the thread for use with BizHawk/Octoshock.
Language: lua
function generateCrit(luck, level, foelevel)
sum = mainmemory.read_u8(luck) + mainmemory.read_u8(level) - mainmemory.read_u8(foelevel)
div = math.floor(sum / 4)
return div
end
function generateRNG(addr1, addr2, addr3)
step1 = mainmemory.read_u8((addr2 + mainmemory.read_s32_le(addr3) + 1) % 8)
step2 = mainmemory.read_u8(addr1 + step1)
step3 = mainmemory.read_u8((addr2 + mainmemory.read_s32_le(addr3) + 2) % 8)
step4 = mainmemory.read_u8(addr1 + step3)
step5 = step4 * 256
step6 = step2 + step5
return math.floor((step6*99)/65535)+1
end
while true do
crit1 = generateCrit(0xf83f5, 0xf83e9, 0xf8589)
crit2 = generateCrit(0xf845d, 0xf8451, 0xf8589)
crit3 = generateCrit(0xf84c5, 0xf84b9, 0xf8589)
crit_rng = generateRNG(0x83084, 0x62e10, 0x62e18)
if crit1>=crit_rng then
gui.text(0,50,"Critical Hit from Character 1!")
else
gui.text(0,50,"")
end
if crit2>=crit_rng then
gui.text(0,60,"Critical Hit from Character 2!")
else
gui.text(0,60,"")
end
if crit3>=crit_rng then
gui.text(0,70,"Critical Hit from Character 3!")
else
gui.text(0,70,"")
end
gui.text(0,30,"Enemy 1 crit% = " .. crit1 .. " " .. crit2 .. " " ..crit3)
gui.text(0,40,"crit_rng = " .. crit_rng)
emu.frameadvance()
end
Addresses should mostly be right (they're known values for the most part) but the script as implemented here is probably very
wrong, which a large part of that can be attributed to me not constantly checking against the asm as I converted the script. I need to better learn
the underlying asm so that I can reimplement this accurately.