Language: lua
address = 0x09c75c
memory_bank_offset = 0x80000000
character_offset = 0x84
files = {
[0]=io.open("cloud.txt", "w+"),
io.open("barret.txt", "w+"),
io.open("tifa.txt", "w+"),
io.open("aeri.txt", "w+"),
io.open("nanaki.txt", "w+"),
io.open("yuffie.txt", "w+"),
io.open("reeve.txt", "w+"),
io.open("vincent.txt", "w+"),
io.open("cid.txt", "w+")
}
function setAeri()
value = mainmemory.read_u8(address)
if (value >= 0x100) then
value = value % 256
elseif (value >=0) then
timer = bit.band(value,1)
if timer == 0 then
mainmemory.write_u8(0x09C8D8, 0x54)
mainmemory.write_u8(0x09C8D9, 0x48)
console.log("Aerith")
elseif timer == 1 then
mainmemory.write_u8(0x09C8D8, 0x53)
mainmemory.write_u8(0x09C8D9, 0xFF)
console.log("Aeris")
else
console.log("Value is neither odd nor even")
end
else
console.log("I was passed a negative value")
end
writeKillCountToFile(0)
end
function writeKillCountToFile(index)
f = files[index]
location = address + (character_offset * index)
result = mainmemory.read_u8(location)
f:seek("set")
f:write(result)
f:flush()
end
event.onmemorywrite(function() setAeri() end, memory_bank_offset + address, "setAeri")
for i=1,8 do
event.onmemorywrite(function() writeKillCountToFile(i) end, memory_bank_offset + address + (character_offset * i), "charIndex"..i)
end
This appears to work as I need it to. There may be issues with the file not getting clobbered correctly when a kill count exceeds 255 (since I'm only doing a read_u8 and I'm not
actually clobbering the file after initialization), but that's a simple fix.
Please note that there is a flaw with this script - as it stands, it is a full battle behind. I'll do some science this coming week to see if I can fix that.